1. 13 8月, 2022 1 次提交
  2. 03 8月, 2022 1 次提交
    • I
      perf parse-events: Break out tracepoint and printing · 9b7c7728
      Ian Rogers 提交于
      Move print_*_events functions out of parse-events.c into a new
      print-events.c. Move tracepoint code into tracepoint.c or
      trace-event-info.c (sole user). This reduces the dependencies of
      parse-events.c and makes it more amenable to being a library in the
      future.
      
      Remove some unnecessary definitions from parse-events.h. Fix a
      checkpatch.pl warning on using unsigned rather than unsigned int.  Fix
      some line length warnings too.
      Signed-off-by: NIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Mark Rutland <mark.rutland@arm.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Cc: Stephane Eranian <eranian@google.com>
      Link: https://lore.kernel.org/r/20220729204217.250166-3-irogers@google.com
      [ Add include linux/stddef.h before perf_events.h for systems where __always_inline isn't pulled in before used, such as older Alpine Linux ]
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      9b7c7728
  3. 17 7月, 2022 1 次提交
    • N
      perf trace: Fix SIGSEGV when processing syscall args · 4b335e1e
      Naveen N. Rao 提交于
      On powerpc, 'perf trace' is crashing with a SIGSEGV when trying to
      process a perf.data file created with 'perf trace record -p':
      
        #0  0x00000001225b8988 in syscall_arg__scnprintf_augmented_string <snip> at builtin-trace.c:1492
        #1  syscall_arg__scnprintf_filename <snip> at builtin-trace.c:1492
        #2  syscall_arg__scnprintf_filename <snip> at builtin-trace.c:1486
        #3  0x00000001225bdd9c in syscall_arg_fmt__scnprintf_val <snip> at builtin-trace.c:1973
        #4  syscall__scnprintf_args <snip> at builtin-trace.c:2041
        #5  0x00000001225bff04 in trace__sys_enter <snip> at builtin-trace.c:2319
      
      That points to the below code in tools/perf/builtin-trace.c:
      	/*
      	 * If this is raw_syscalls.sys_enter, then it always comes with the 6 possible
      	 * arguments, even if the syscall being handled, say "openat", uses only 4 arguments
      	 * this breaks syscall__augmented_args() check for augmented args, as we calculate
      	 * syscall->args_size using each syscalls:sys_enter_NAME tracefs format file,
      	 * so when handling, say the openat syscall, we end up getting 6 args for the
      	 * raw_syscalls:sys_enter event, when we expected just 4, we end up mistakenly
      	 * thinking that the extra 2 u64 args are the augmented filename, so just check
      	 * here and avoid using augmented syscalls when the evsel is the raw_syscalls one.
      	 */
      	if (evsel != trace->syscalls.events.sys_enter)
      		augmented_args = syscall__augmented_args(sc, sample, &augmented_args_size, trace->raw_augmented_syscalls_args_size);
      
      As the comment points out, we should not be trying to augment the args
      for raw_syscalls. However, when processing a perf.data file, we are not
      initializing those properly. Fix the same.
      Reported-by: NClaudio Carvalho <cclaudio@linux.ibm.com>
      Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Link: http://lore.kernel.org/lkml/20220707090900.572584-1-naveen.n.rao@linux.vnet.ibm.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4b335e1e
  4. 17 2月, 2022 1 次提交
    • C
      perf trace: Avoid early exit due SIGCHLD from non-workload processes · de9f498d
      Changbin Du 提交于
      The function trace__symbols_init() runs "perf-read-vdso32" and that ends up
      with a SIGCHLD delivered to 'perf'. And this SIGCHLD make perf exit early.
      
      'perf trace' should exit only if the SIGCHLD is from our workload process.
      So let's use sigaction() instead of signal() to match such condition.
      
      Committer notes:
      
      Use memset to zero the 'struct sigaction' variable as the '= { 0 }'
      method isn't accepted in many compiler versions, e.g.:
      
         4    34.02 alpine:3.6                    : FAIL clang version 4.0.0 (tags/RELEASE_400/final)
          builtin-trace.c:4897:35: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                  struct sigaction sigchld_act = { 0 };
                                                   ^
                                                   {}
          builtin-trace.c:4897:37: error: missing field 'sa_mask' initializer [-Werror,-Wmissing-field-initializers]
                  struct sigaction sigchld_act = { 0 };
                                                     ^
          2 errors generated.
         6    32.60 alpine:3.8                    : FAIL gcc version 6.4.0 (Alpine 6.4.0)
          builtin-trace.c:4897:35: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                  struct sigaction sigchld_act = { 0 };
                                                   ^
                                                   {}
          builtin-trace.c:4897:37: error: missing field 'sa_mask' initializer [-Werror,-Wmissing-field-initializers]
                  struct sigaction sigchld_act = { 0 };
                                                     ^
          2 errors generated.
         7    34.82 alpine:3.9                    : FAIL gcc version 8.3.0 (Alpine 8.3.0)
          builtin-trace.c:4897:35: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                  struct sigaction sigchld_act = { 0 };
                                                   ^
                                                   {}
          builtin-trace.c:4897:37: error: missing field 'sa_mask' initializer [-Werror,-Wmissing-field-initializers]
                  struct sigaction sigchld_act = { 0 };
                                                     ^
          2 errors generated.
      Signed-off-by: NChangbin Du <changbin.du@gmail.com>
      Acked-by: NJiri Olsa <jolsa@kernel.org>
      Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.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>
      Link: https://lore.kernel.org/r/20220208140725.3947-1-changbin.du@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      de9f498d
  5. 11 2月, 2022 1 次提交
  6. 08 1月, 2022 1 次提交
  7. 15 12月, 2021 1 次提交
  8. 08 12月, 2021 1 次提交
  9. 07 12月, 2021 1 次提交
  10. 12 11月, 2021 2 次提交
    • A
      perf trace: Beautify the 'level' argument of setsockopt · 0826b7fd
      Arnaldo Carvalho de Melo 提交于
        # perf trace -e setsockopt
           0.000 ( 0.019 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 50, optval: 0x7ffee2c0c134, optlen: 4) = 0
           0.022 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 11, optval: 0x7ffee2c0c114, optlen: 4) = 0
           0.027 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 8, optval: 0x7ffee2c0c134, optlen: 4) = 0
           0.032 ( 0.002 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 10, optval: 0x7ffee2c0c134, optlen: 4) = 0
           0.036 ( 0.002 ms): systemd-resolv/1121 setsockopt(fd: 22, level: IP, optname: 25, optval: 0x7ffee2c0c114, optlen: 4) = 0
           0.043 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: 1, optname: 62, optval: 0x7ffee2c0c0fc, optlen: 4) = 0
           0.055 ( 0.003 ms): systemd-resolv/1121 setsockopt(fd: 22, level: 1, optname: 25)
        ^C#
      
      So the simple straight STRARRAY method is not enough as SOL_SOCKET is
      '1' in most architectures but some use 0xffff (alpha, mips, parisc and
      sparc), so a followup patch will create a specialized scnprintf to cover
      that.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      0826b7fd
    • A
      perf trace: Beautify the 'level' argument of getsockopt · f1c1e45e
      Arnaldo Carvalho de Melo 提交于
        # perf trace -e getsockopt
             0.000 ( 0.006 ms): systemd-resolv/1121 getsockopt(fd: 21, level: 1, optname: 17, optval: 0x7ffee2c0c6cc, optlen: 0x7ffee2c0c6c8) = 0
             0.301 ( 0.003 ms): systemd-resolv/1121 getsockopt(fd: 22, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
             2.215 ( 0.005 ms): systemd-resolv/1121 getsockopt(fd: 21, level: 1, optname: 17, optval: 0x7ffee2c0c6cc, optlen: 0x7ffee2c0c6c8) = 0
             2.422 ( 0.005 ms): systemd-resolv/1121 getsockopt(fd: 22, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
          1001.308 ( 0.006 ms): systemd-resolv/1121 getsockopt(fd: 21, level: 1, optname: 17, optval: 0x7ffee2c0c6cc, optlen: 0x7ffee2c0c6c8) = 0
          1001.586 ( 0.003 ms): systemd-resolv/1121 getsockopt(fd: 22, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
          1001.647 ( 0.002 ms): systemd-resolv/1121 getsockopt(fd: 23, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
          1003.868 ( 0.010 ms): systemd-resolv/1121 getsockopt(fd: 21, level: 1, optname: 17, optval: 0x7ffee2c0c6cc, optlen: 0x7ffee2c0c6c8) = 0
          1004.036 ( 0.006 ms): systemd-resolv/1121 getsockopt(fd: 22, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
          1004.087 ( 0.002 ms): systemd-resolv/1121 getsockopt(fd: 23, level: IP, optname: 14, optval: 0x7ffee2c0c1a0, optlen: 0x7ffee2c0c1a4) = -1 ENOTCONN (Transport endpoint is not connected)
        ^C#
      
      So the simple straight STRARRAY method is not enough as SOL_SOCKET is
      '1' in most architectures but some use 0xffff (alpha, mips, parisc and
      sparc), so a followup patch will create a specialized scnprintf to cover
      that.
      Signed-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      f1c1e45e
  11. 08 11月, 2021 2 次提交
  12. 17 9月, 2021 1 次提交
  13. 02 8月, 2021 2 次提交
  14. 16 7月, 2021 4 次提交
  15. 07 3月, 2021 1 次提交
  16. 01 12月, 2020 4 次提交
  17. 30 11月, 2020 4 次提交
  18. 03 11月, 2020 1 次提交
  19. 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
  20. 04 8月, 2020 1 次提交
  21. 23 6月, 2020 2 次提交
  22. 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
  23. 28 5月, 2020 2 次提交
  24. 06 5月, 2020 3 次提交