1. 02 8月, 2021 2 次提交
  2. 16 7月, 2021 4 次提交
  3. 07 3月, 2021 1 次提交
  4. 01 12月, 2020 4 次提交
  5. 30 11月, 2020 4 次提交
  6. 03 11月, 2020 1 次提交
  7. 14 10月, 2020 1 次提交
    • J
      perf trace: Fix off by ones in memset() after realloc() in arches using libaudit · f3013f7e
      Jiri Slaby 提交于
      'perf trace ls' started crashing after commit d21cb73a on
      !HAVE_SYSCALL_TABLE_SUPPORT configs (armv7l here) like this:
      
        0  strlen () at ../sysdeps/arm/armv6t2/strlen.S:126
        1  0xb6800780 in __vfprintf_internal (s=0xbeff9908, s@entry=0xbeff9900, format=0xa27160 "]: %s()", ap=..., mode_flags=<optimized out>) at vfprintf-internal.c:1688
        ...
        5  0x0056ecdc in fprintf (__fmt=0xa27160 "]: %s()", __stream=<optimized out>) at /usr/include/bits/stdio2.h:100
        6  trace__sys_exit (trace=trace@entry=0xbeffc710, evsel=evsel@entry=0xd968d0, event=<optimized out>, sample=sample@entry=0xbeffc3e8) at builtin-trace.c:2475
        7  0x00566d40 in trace__handle_event (sample=0xbeffc3e8, event=<optimized out>, trace=0xbeffc710) at builtin-trace.c:3122
        ...
        15 main (argc=2, argv=0xbefff6e8) at perf.c:538
      
      It is because memset in trace__read_syscall_info zeroes wrong memory:
      
      1) when initializing for the first time, it does not reset the last id.
      
      2) in other cases, it resets the last id of previous buffer.
      
      ad 1) it causes the crash above as sc->name used in the fprintf above
            contains garbage.
      
      ad 2) it sets nonexistent from true back to false for id 11 here. Not
            sure, what the consequences are.
      
      So fix it by introducing a special case for the initial initialization
      and do the right +1 in both cases.
      
      Fixes: d21cb73a ("perf trace: Grow the syscall table as needed when using libaudit")
      Signed-off-by: NJiri Slaby <jslaby@suse.cz>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: http://lore.kernel.org/lkml/20201001093419.15761-1-jslaby@suse.czSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f3013f7e
  8. 04 8月, 2020 1 次提交
  9. 23 6月, 2020 2 次提交
  10. 30 5月, 2020 1 次提交
    • A
      perf trace: Grow the syscall table as needed when using libaudit · d21cb73a
      Arnaldo Carvalho de Melo 提交于
      The audit-libs API doesn't provide a way to figure out what is the
      syscall with the greatest number/id, take that into account when using
      that method to go on growing the syscall table as we the syscalls go on
      appearing on the radar.
      
      With this the libaudit based method is back working, i.e. when building
      with:
      
        $ make NO_SYSCALL_TABLE=1 O=/tmp/build/perf -C tools/perf install-bin
        <SNIP>
        Auto-detecting system features:
        <SNIP>
        ...                      libaudit: [ on  ]
        ...                        libbfd: [ on  ]
        ...                        libcap: [ on  ]
        <SNIP>
        $ ldd ~/bin/perf | grep audit
      	libaudit.so.1 => /lib64/libaudit.so.1 (0x00007faef22df000)
        $
      
      perf trace is back working, which makes it functional in arches other
      than x86_64, powerpc, arm64 and s390, that provides these generators:
      
        $ find tools/perf/arch/ -name "*syscalltbl*"
        tools/perf/arch/x86/entry/syscalls/syscalltbl.sh
        tools/perf/arch/arm64/entry/syscalls/mksyscalltbl
        tools/perf/arch/s390/entry/syscalls/mksyscalltbl
        tools/perf/arch/powerpc/entry/syscalls/mksyscalltbl
        $
      
      Example output forcing the libaudit method on x86_64:
      
        # perf trace -e file,nanosleep sleep 0.001
                 ? (         ): sleep/859090  ... [continued]: execve())                                   = 0
             0.045 ( 0.005 ms): sleep/859090 access(filename: 0x8733e850, mode: R)                         = -1 ENOENT (No such file or directory)
             0.055 ( 0.005 ms): sleep/859090 openat(dfd: CWD, filename: 0x8733ba29, flags: RDONLY|CLOEXEC) = 3
             0.079 ( 0.005 ms): sleep/859090 openat(dfd: CWD, filename: 0x87345d20, flags: RDONLY|CLOEXEC) = 3
             0.085 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483f58, count: 832)                  = 832
             0.090 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483b50, count: 784)                  = 784
             0.094 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483b20, count: 32)                   = 32
             0.098 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483ad0, count: 68)                   = 68
             0.109 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483a50, count: 784)                  = 784
             0.113 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483730, count: 32)                   = 32
             0.117 ( 0.002 ms): sleep/859090 read(fd: 3, buf: 0x7ffd9d483710, count: 68)                   = 68
             0.320 ( 0.008 ms): sleep/859090 openat(dfd: CWD, filename: 0x872c3660, flags: RDONLY|CLOEXEC) = 3
             0.372 ( 1.057 ms): sleep/859090 nanosleep(rqtp: 0x7ffd9d484ac0)                               = 0
        #
      
      There are still some limitations when using the libaudit method, that
      will be fixed at some point, i.e., this works with the mksyscalltbl
      method but not with libaudit's:
      
        # perf trace -e file,*sleep sleep 0.001
        event syntax error: '*sleep'
                             \___ parser error
        Run 'perf list' for a list of valid events
      
         Usage: perf trace [<options>] [<command>]
            or: perf trace [<options>] -- <command> [<options>]
            or: perf trace record [<options>] [<command>]
            or: perf trace record [<options>] -- <command> [<options>]
      
            -e, --event <event>   event/syscall selector. use 'perf list' to list available events
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Ingo Molnar <mingo@kernel.org>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d21cb73a
  11. 28 5月, 2020 2 次提交
  12. 06 5月, 2020 7 次提交
  13. 12 2月, 2020 1 次提交
    • A
      perf trace: Resolve prctl's 'option' arg strings to numbers · d7a07b29
      Arnaldo Carvalho de Melo 提交于
        # perf trace -e syscalls:sys_enter_prctl --filter="option==SET_NAME"
           0.000 Socket Thread/3860 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7fc50b9733e8)
           0.053 SSL Cert #78/3860 syscalls:sys_enter_prctl(option: SET_NAME, arg2: 0x7fc50b9733e8)
      ^C  #
      
      If one uses '-v' with 'perf trace', we can see the filter it puts in
      place:
      
        New filter for syscalls:sys_enter_prctl: (option==0xf) && (common_pid != 3859 && common_pid != 2757)
      
      We still need to allow using plain '-e prctl' and have this turn into
      creating a 'syscalls:sys_enter_prctl' event so that the filter can be
      applied only to it as right now '-e prctl' ends up using the
      'raw_syscalls:sys_enter/sys_exit'.
      
      The end goal is to have something like:
      
        # perf trace -e prctl/option==SET_NAME/
      
      And have that use tracepoint filters or eBPF ones.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Christian Brauner <christian.brauner@ubuntu.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mike Christie <mchristi@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      d7a07b29
  14. 19 11月, 2019 1 次提交
    • I
      perf parse: Report initial event parsing error · a910e466
      Ian Rogers 提交于
      Record the first event parsing error and report. Implementing feedback
      from Jiri Olsa:
      
        https://lkml.org/lkml/2019/10/28/680
      
      An example error is:
      
        $ tools/perf/perf stat -e c/c/
        WARNING: multiple event parsing errors
        event syntax error: 'c/c/'
                               \___ unknown term
      
        valid terms: event,filter_rem,filter_opc0,edge,filter_isoc,filter_tid,filter_loc,filter_nc,inv,umask,filter_opc1,tid_en,thresh,filter_all_op,filter_not_nm,filter_state,filter_nm,config,config1,config2,name,period,percore
      
      Initial error:
      
        event syntax error: 'c/c/'
                            \___ Cannot find PMU `c'. Missing kernel support?
        Run 'perf list' for a list of valid events
      
         Usage: perf stat [<options>] [<command>]
      
            -e, --event <event>   event selector. use 'perf list' to list available events
      Signed-off-by: NIan Rogers <irogers@google.com>
      Tested-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Allison Randal <allison@lohutok.net>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Anju T Sudhakar <anju@linux.vnet.ibm.com>
      Cc: Christian Borntraeger <borntraeger@de.ibm.com>
      Cc: Davidlohr Bueso <dave@stgolabs.net>
      Cc: Jin Yao <yao.jin@linux.intel.com>
      Cc: Jiri Olsa <jolsa@redhat.com>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
      Cc: Stephane Eranian <eranian@google.com>
      Cc: Thomas Gleixner <tglx@linutronix.de>
      Cc: Thomas Richter <tmricht@linux.ibm.com>
      Link: http://lore.kernel.org/lkml/20191116074652.9960-1-irogers@google.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a910e466
  15. 20 10月, 2019 6 次提交
    • A
      perf trace: Use STUL_STRARRAY_FLAGS with mmap · 27198a89
      Arnaldo Carvalho de Melo 提交于
      The 'mmap' syscall has special needs so it doesn't use
      SCA_STRARRAY_FLAGS, see its implementation in
      syscall_arg__scnprintf_mmap_flags(), related to special handling of
      MAP_ANONYMOUS, so set ->parm to the strarray__mmap_flags and hook up
      with strarray__strtoul_flags manually, now we can filter by those or-ed
      string expressions:
      
        # perf trace -e syscalls:sys_enter_mmap sleep 1
           0.000 syscalls:sys_enter_mmap(addr: NULL, len: 134346, prot: READ, flags: PRIVATE, fd: 3, off: 0)
           0.026 syscalls:sys_enter_mmap(addr: NULL, len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS)
           0.036 syscalls:sys_enter_mmap(addr: NULL, len: 1857472, prot: READ, flags: PRIVATE|DENYWRITE, fd: 3, off: 0)
           0.046 syscalls:sys_enter_mmap(addr: 0x7fae003d9000, len: 1363968, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x22000)
           0.052 syscalls:sys_enter_mmap(addr: 0x7fae00526000, len: 311296, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x16f000)
           0.055 syscalls:sys_enter_mmap(addr: 0x7fae00573000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x1bb000)
           0.062 syscalls:sys_enter_mmap(addr: 0x7fae00579000, len: 14272, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS)
           0.253 syscalls:sys_enter_mmap(addr: NULL, len: 217750512, prot: READ, flags: PRIVATE, fd: 3, off: 0)
        #
      
        # perf trace -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|FIXED|DENYWRITE" sleep 1
           0.000 syscalls:sys_enter_mmap(addr: 0x7f6ab3dcb000, len: 1363968, prot: READ|EXEC, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x22000)
           0.010 syscalls:sys_enter_mmap(addr: 0x7f6ab3f18000, len: 311296, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x16f000)
           0.014 syscalls:sys_enter_mmap(addr: 0x7f6ab3f65000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 0x1bb000)
        # perf trace -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|ANONYMOUS" sleep 1
           0.000 syscalls:sys_enter_mmap(addr: NULL, len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS)
        #
      
        # perf trace -v -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|ANONYMOUS" sleep 1 |& grep "New filter"
        New filter for syscalls:sys_enter_mmap: flags==0x22
        #
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-czw754b7m9rp9ibq2f6be2o1@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      27198a89
    • A
      perf trace: Wire up strarray__strtoul_flags() · e0712baa
      Arnaldo Carvalho de Melo 提交于
      Now anything that uses STRARRAY_FLAGS, like the 'fsmount' syscall will
      support mapping or-ed strings back to a value that can be used in a
      filter.
      
      In some cases, where STRARRAY_FLAGS isn't used but instead the scnprintf
      is a special one because of specific needs, like for mmap, then one has
      to set the ->pars to the strarray. See the next cset.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-r2lpqo7dfsrhi4ll0npsb3u7@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e0712baa
    • A
      libbeauty: Introduce strarray__strtoul_flags() · 154c978d
      Arnaldo Carvalho de Melo 提交于
      Counterpart of strarray__scnprintf_flags(), i.e. from a expression like:
      
         # perf trace -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|FIXED|DENYWRITE"
      
      I.e. that "flags==PRIVATE|FIXED|DENYWRITE", turn that into
      
         # perf trace -e syscalls:sys_enter_mmap --filter=0x812
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-8xst3zrqqogax7fmfzwymvbl@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      154c978d
    • A
      perf trace: Use strtoul for the fcntl 'cmd' argument · 82c38338
      Arnaldo Carvalho de Melo 提交于
      Since its values are in two ranges of values we ended up codifying it
      using a 'struct strarrays', so now hook it up with STUL_STRARRAYS so
      that we can do:
      
        # perf trace -e syscalls:*enter_fcntl --filter=cmd==SETLK||cmd==SETLKW
           0.000 sssd_kcm/19021 syscalls:sys_enter_fcntl(fd: 13</var/lib/sss/secrets/secrets.ldb>, cmd: SETLK, arg: 0x7ffcf0a4dee0)
           1.523 sssd_kcm/19021 syscalls:sys_enter_fcntl(fd: 13</var/lib/sss/secrets/secrets.ldb>, cmd: SETLK, arg: 0x7ffcf0a4de90)
           1.629 sssd_kcm/19021 syscalls:sys_enter_fcntl(fd: 13</var/lib/sss/secrets/secrets.ldb>, cmd: SETLK, arg: 0x7ffcf0a4de90)
           2.711 sssd_kcm/19021 syscalls:sys_enter_fcntl(fd: 13</var/lib/sss/secrets/secrets.ldb>, cmd: SETLK, arg: 0x7ffcf0a4de70)
        ^C#
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-mob96wyzri4r3rvyigqfjv0a@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      82c38338
    • A
      libbeauty: Introduce syscall_arg__strtoul_strarrays() · 1a8a90b8
      Arnaldo Carvalho de Melo 提交于
      To allow going from string to integer for 'struct strarrays'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-b1ia3xzcy72hv0u4m168fcd0@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1a8a90b8
    • A
      perf trace: Pass a syscall_arg to syscall_arg_fmt->strtoul() · 9afec87e
      Arnaldo Carvalho de Melo 提交于
      With just what we need for the STUL_STRARRAY, i.e. the 'struct strarray'
      pointer to be used, just like with syscall_arg_fmt->scnprintf() for the
      other direction (number -> string).
      
      With this all the strarrays that are associated with syscalls can be
      used with '-e syscalls:sys_enter_SYSCALLNAME --filter', and soon will be
      possible as well to use with the strace-like shorter form, with just the
      syscall names, i.e. something like:
      
         -e lseek/whence==END/
      
      For now we have to use the longer form:
      
          # perf trace -e syscalls:sys_enter_lseek
             0.000 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
             0.031 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
             0.046 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.528 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.575 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
          5003.593 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.017 pool/2242 syscalls:sys_enter_lseek(fd: 14<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.051 pool/2242 syscalls:sys_enter_lseek(fd: 15<anon_inode:[timerfd]>, offset: 0, whence: CUR)
         10002.068 pool/2242 syscalls:sys_enter_lseek(fd: 16<anon_inode:[timerfd]>, offset: 0, whence: CUR)
        ^C# perf trace -e syscalls:sys_enter_lseek --filter="whence!=CUR"
             0.000 sshd/24476 syscalls:sys_enter_lseek(fd: 3, offset: 9032, whence: SET)
             0.060 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 9032, whence: SET)
             0.187 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 118632, whence: SET)
             0.203 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 118632, whence: SET)
             0.349 sshd/24476 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libcrypt.so.2.0.0>, offset: 61936, whence: SET)
        ^C#
      
      And for those curious about what are those lseek(DSO, offset, SET), well, its the loader:
      
        # perf trace -e syscalls:sys_enter_lseek/max-stack=16/ --filter="whence!=CUR"
           0.000 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 9032, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.067 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 9032, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object_from_fd (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.198 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 118632, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
           0.219 sshd/24495 syscalls:sys_enter_lseek(fd: 3</usr/lib64/libgcrypt.so.20.2.5>, offset: 118632, whence: SET)
                                             __libc_lseek64 (/usr/lib64/ld-2.29.so)
                                             _dl_map_object_from_fd (/usr/lib64/ld-2.29.so)
                                             _dl_map_object (/usr/lib64/ld-2.29.so)
        ^C#
      
      :-)
      
      With this we can use strings in strarrays in filters, which allows us to
      reuse all these that are in place for syscalls:
      
        $ find tools/perf/trace/beauty/ -name "*.c" | xargs grep -w DEFINE_STRARRAY
        tools/perf/trace/beauty/fcntl.c:	static DEFINE_STRARRAY(fcntl_setlease, "F_");
        tools/perf/trace/beauty/mmap.c:       static DEFINE_STRARRAY(mmap_flags, "MAP_");
        tools/perf/trace/beauty/mmap.c:       static DEFINE_STRARRAY(madvise_advices, "MADV_");
        tools/perf/trace/beauty/sync_file_range.c:       static DEFINE_STRARRAY(sync_file_range_flags, "SYNC_FILE_RANGE_");
        tools/perf/trace/beauty/socket.c:	static DEFINE_STRARRAY(socket_ipproto, "IPPROTO_");
        tools/perf/trace/beauty/mount_flags.c:	static DEFINE_STRARRAY(mount_flags, "MS_");
        tools/perf/trace/beauty/pkey_alloc.c:	static DEFINE_STRARRAY(pkey_alloc_access_rights, "PKEY_");
        tools/perf/trace/beauty/sockaddr.c:DEFINE_STRARRAY(socket_families, "PF_");
        tools/perf/trace/beauty/tracepoints/x86_irq_vectors.c:static DEFINE_STRARRAY(x86_irq_vectors, "_VECTOR");
        tools/perf/trace/beauty/tracepoints/x86_msr.c:static DEFINE_STRARRAY(x86_MSRs, "MSR_");
        tools/perf/trace/beauty/prctl.c:	static DEFINE_STRARRAY(prctl_options, "PR_");
        tools/perf/trace/beauty/prctl.c:	static DEFINE_STRARRAY(prctl_set_mm_options, "PR_SET_MM_");
        tools/perf/trace/beauty/fspick.c:       static DEFINE_STRARRAY(fspick_flags, "FSPICK_");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(ioctl_tty_cmd, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(drm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(sndrv_pcm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(sndrv_ctl_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(kvm_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(vhost_virtio_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(vhost_virtio_ioctl_read_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(perf_ioctl_cmds, "");
        tools/perf/trace/beauty/ioctl.c:	static DEFINE_STRARRAY(usbdevfs_ioctl_cmds, "");
        tools/perf/trace/beauty/fsmount.c:       static DEFINE_STRARRAY(fsmount_attr_flags, "MOUNT_ATTR_");
        tools/perf/trace/beauty/renameat.c:       static DEFINE_STRARRAY(rename_flags, "RENAME_");
        tools/perf/trace/beauty/kcmp.c:	static DEFINE_STRARRAY(kcmp_types, "KCMP_");
        tools/perf/trace/beauty/move_mount.c:       static DEFINE_STRARRAY(move_mount_flags, "MOVE_MOUNT_");
        $
      
      Well, some, as the mmap flags are like:
      
        $ tools/perf/trace/beauty/mmap_flags.sh
        static const char *mmap_flags[] = {
        	[ilog2(0x40) + 1] = "32BIT",
        	[ilog2(0x01) + 1] = "SHARED",
        	[ilog2(0x02) + 1] = "PRIVATE",
        	[ilog2(0x10) + 1] = "FIXED",
        	[ilog2(0x20) + 1] = "ANONYMOUS",
        	[ilog2(0x008000) + 1] = "POPULATE",
        	[ilog2(0x010000) + 1] = "NONBLOCK",
        	[ilog2(0x020000) + 1] = "STACK",
        	[ilog2(0x040000) + 1] = "HUGETLB",
        	[ilog2(0x080000) + 1] = "SYNC",
        	[ilog2(0x100000) + 1] = "FIXED_NOREPLACE",
        	[ilog2(0x0100) + 1] = "GROWSDOWN",
        	[ilog2(0x0800) + 1] = "DENYWRITE",
        	[ilog2(0x1000) + 1] = "EXECUTABLE",
        	[ilog2(0x2000) + 1] = "LOCKED",
        	[ilog2(0x4000) + 1] = "NORESERVE",
        };
        $
      
      So we'll need a strarray__strtoul_flags() that will break donw the flags
      into tokens separated by '|' before doing the lookup and then go on
      reconstructing the value from, say:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==PRIVATE|FIXED|DENYWRITE"
      
      into:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==0x2|0x10|0x0800"
      
      and finally into:
      
            # perf trace -e syscalls:sys_enter_mmap --filter="flags==0x812"
      
      That is what we see if we don't use the augmented view obtained from:
      
        # perf trace -e mmap
        <SNIP>
        211792.885 procmail/15393 mmap(addr: 0x7fcd11645000, len: 8192, prot: READ, flags: PRIVATE|FIXED|DENYWRITE, fd: 8, off: 0xa000) = 0x7fcd11645000
        <SNIP>
      
      But plain use tracefs:
      
              procmail-15559 [000] .... 54557.178262: sys_mmap(addr: 7f5c9bf7a000, len: 9b000, prot: 1, flags: 812, fd: 3, off: a9000)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Brendan Gregg <brendan.d.gregg@gmail.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Luis Cláudio Gonçalves <lclaudio@redhat.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: https://lkml.kernel.org/n/tip-c6mgkjt8ujnc263eld5tb7q3@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9afec87e
  16. 18 10月, 2019 2 次提交