mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-26 21:54:11 +08:00
388968d864
No change in behaviour: # perf trace -e mmap sleep 1 0.000 ( 0.009 ms): sleep/751870 mmap(len: 143317, prot: READ, flags: PRIVATE, fd: 3) = 0x7fa96d0f7000 0.028 ( 0.004 ms): sleep/751870 mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS) = 0x7fa96d0f5000 0.037 ( 0.005 ms): sleep/751870 mmap(len: 1872744, prot: READ, flags: PRIVATE|DENYWRITE, fd: 3) = 0x7fa96cf2b000 0.044 ( 0.011 ms): sleep/751870 mmap(addr: 0x7fa96cf50000, len: 1376256, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x25000) = 0x7fa96cf50000 0.056 ( 0.007 ms): sleep/751870 mmap(addr: 0x7fa96d0a0000, len: 307200, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x175000) = 0x7fa96d0a0000 0.064 ( 0.007 ms): sleep/751870 mmap(addr: 0x7fa96d0eb000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x1bf000) = 0x7fa96d0eb000 0.075 ( 0.005 ms): sleep/751870 mmap(addr: 0x7fa96d0f1000, len: 13160, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) = 0x7fa96d0f1000 0.253 ( 0.005 ms): sleep/751870 mmap(len: 218049136, prot: READ, flags: PRIVATE, fd: 3) = 0x7fa95ff38000 # # # set -o vi # strace -e mmap sleep 1 mmap(NULL, 143317, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f333bd83000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f333bd81000 mmap(NULL, 1872744, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f333bbb7000 mmap(0x7f333bbdc000, 1376256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f333bbdc000 mmap(0x7f333bd2c000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x175000) = 0x7f333bd2c000 mmap(0x7f333bd77000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f333bd77000 mmap(0x7f333bd7d000, 13160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f333bd7d000 mmap(NULL, 218049136, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f332ebc4000 +++ exited with 0 +++ # And you can as well tweak 'perf trace's output to more closely match strace's: # perf config trace.show_arg_names=no # perf config trace.show_duration=no # perf config trace.show_prefix=yes # perf config trace.show_timestamp=no # perf config trace.show_zeros=yes # perf config trace.no_inherit=yes # perf trace -e mmap sleep 1 mmap(NULL, 143317, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0d287ca000 mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS) = 0x7f0d287c8000 mmap(NULL, 1872744, PROT_READ, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f0d285fe000 mmap(0x7f0d28623000, 1376256, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x25000) = 0x7f0d28623000 mmap(0x7f0d28773000, 307200, PROT_READ, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x175000) = 0x7f0d28773000 mmap(0x7f0d287be000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1bf000) = 0x7f0d287be000 mmap(0x7f0d287c4000, 13160, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS) = 0x7f0d287c4000 mmap(NULL, 218049136, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f0d1b60b000 # # perf config | grep ^trace trace.show_arg_names=no trace.show_duration=no trace.show_prefix=yes trace.show_timestamp=no trace.show_zeros=yes trace.no_inherit=yes # Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
83 lines
2.7 KiB
C
83 lines
2.7 KiB
C
// SPDX-License-Identifier: LGPL-2.1
|
|
#include <linux/log2.h>
|
|
|
|
#include "trace/beauty/generated/mmap_prot_array.c"
|
|
static DEFINE_STRARRAY(mmap_prot, "PROT_");
|
|
|
|
static size_t mmap__scnprintf_prot(unsigned long prot, char *bf, size_t size, bool show_prefix)
|
|
{
|
|
return strarray__scnprintf_flags(&strarray__mmap_prot, bf, size, show_prefix, prot);
|
|
}
|
|
|
|
static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size, struct syscall_arg *arg)
|
|
{
|
|
unsigned long prot = arg->val;
|
|
|
|
if (prot == 0)
|
|
return scnprintf(bf, size, "%sNONE", arg->show_string_prefix ? strarray__mmap_prot.prefix : "");
|
|
|
|
return mmap__scnprintf_prot(prot, bf, size, arg->show_string_prefix);
|
|
}
|
|
|
|
#define SCA_MMAP_PROT syscall_arg__scnprintf_mmap_prot
|
|
|
|
#include "trace/beauty/generated/mmap_flags_array.c"
|
|
static DEFINE_STRARRAY(mmap_flags, "MAP_");
|
|
|
|
static size_t mmap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
|
|
{
|
|
return strarray__scnprintf_flags(&strarray__mmap_flags, bf, size, show_prefix, flags);
|
|
}
|
|
|
|
static size_t syscall_arg__scnprintf_mmap_flags(char *bf, size_t size,
|
|
struct syscall_arg *arg)
|
|
{
|
|
unsigned long flags = arg->val;
|
|
|
|
if (flags & MAP_ANONYMOUS)
|
|
arg->mask |= (1 << 4) | (1 << 5); /* Mask 4th ('fd') and 5th ('offset') args, ignored */
|
|
|
|
return mmap__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
|
|
}
|
|
|
|
#define SCA_MMAP_FLAGS syscall_arg__scnprintf_mmap_flags
|
|
|
|
#include "trace/beauty/generated/mremap_flags_array.c"
|
|
static DEFINE_STRARRAY(mremap_flags, "MREMAP_");
|
|
|
|
static size_t mremap__scnprintf_flags(unsigned long flags, char *bf, size_t size, bool show_prefix)
|
|
{
|
|
return strarray__scnprintf_flags(&strarray__mremap_flags, bf, size, show_prefix, flags);
|
|
}
|
|
|
|
static size_t syscall_arg__scnprintf_mremap_flags(char *bf, size_t size, struct syscall_arg *arg)
|
|
{
|
|
unsigned long flags = arg->val;
|
|
|
|
if (!(flags & MREMAP_FIXED))
|
|
arg->mask |= (1 << 5); /* Mask 5th ('new_address') args, ignored */
|
|
|
|
return mremap__scnprintf_flags(flags, bf, size, arg->show_string_prefix);
|
|
}
|
|
|
|
#define SCA_MREMAP_FLAGS syscall_arg__scnprintf_mremap_flags
|
|
|
|
static size_t madvise__scnprintf_behavior(int behavior, char *bf, size_t size)
|
|
{
|
|
#include "trace/beauty/generated/madvise_behavior_array.c"
|
|
static DEFINE_STRARRAY(madvise_advices, "MADV_");
|
|
|
|
if (behavior < strarray__madvise_advices.nr_entries && strarray__madvise_advices.entries[behavior] != NULL)
|
|
return scnprintf(bf, size, "MADV_%s", strarray__madvise_advices.entries[behavior]);
|
|
|
|
return scnprintf(bf, size, "%#", behavior);
|
|
}
|
|
|
|
static size_t syscall_arg__scnprintf_madvise_behavior(char *bf, size_t size,
|
|
struct syscall_arg *arg)
|
|
{
|
|
return madvise__scnprintf_behavior(arg->val, bf, size);
|
|
}
|
|
|
|
#define SCA_MADV_BHV syscall_arg__scnprintf_madvise_behavior
|