1. 21 11月, 2018 13 次提交
    • A
      Revert "perf augmented_syscalls: Drop 'write', 'poll' for testing without self pid filter" · 4aa792de
      Arnaldo Carvalho de Melo 提交于
      Now that we have the "filtered_pids" logic in place, no need to do this
      rough filter to avoid the feedback loop from 'perf trace's own syscalls,
      revert it.
      
      This reverts commit 7ed71f124284359676b6496ae7db724fee9da753.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-88vh02cnkam0vv5f9vp02o3h@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      4aa792de
    • A
      perf augmented_syscalls: Remove example hardcoded set of filtered pids · e312747b
      Arnaldo Carvalho de Melo 提交于
      Now that 'perf trace' fills in that "filtered_pids" BPF map, remove the
      set of filtered pids used as an example to test that feature.
      
      That feature works like this:
      
      Starting a system wide 'strace' like 'perf trace' augmented session we
      noticed that lots of events take place for a pid, which ends up being
      the feedback loop of perf trace's syscalls being processed by the
      'gnome-terminal' process:
      
        # perf trace -e tools/perf/examples/bpf/augmented_raw_syscalls.c
           0.391 ( 0.002 ms): gnome-terminal/2469 read(fd: 17</dev/ptmx>, buf: 0x564b79f750bc, count: 8176) = 453
           0.394 ( 0.001 ms): gnome-terminal/2469 read(fd: 17</dev/ptmx>, buf: 0x564b79f75280, count: 7724) = -1 EAGAIN Resource temporarily unavailable
           0.438 ( 0.001 ms): gnome-terminal/2469 read(fd: 4<anon_inode:[eventfd]>, buf: 0x7fffc696aeb0, count: 16) = 8
           0.519 ( 0.001 ms): gnome-terminal/2469 read(fd: 17</dev/ptmx>, buf: 0x564b79f75280, count: 7724) = 114
           0.522 ( 0.001 ms): gnome-terminal/2469 read(fd: 17</dev/ptmx>, buf: 0x564b79f752f1, count: 7611) = -1 EAGAIN Resource temporarily unavailable
        ^C
      
      So we can use --filter-pids to get rid of that one, and in this case what is
      being used to implement that functionality is that "filtered_pids" BPF map that
      the tools/perf/examples/bpf/augmented_raw_syscalls.c created and that 'perf trace'
      bpf loader noticed and created a "struct bpf_map" associated that then got populated
      by 'perf trace':
      
        # perf trace --filter-pids 2469 -e tools/perf/examples/bpf/augmented_raw_syscalls.c
           0.020 ( 0.002 ms): gnome-shell/1663 epoll_pwait(epfd: 12<anon_inode:[eventpoll]>, events: 0x7ffd8f3ef960, maxevents: 32, sigsetsize: 8) = 1
           0.025 ( 0.002 ms): gnome-shell/1663 read(fd: 24</dev/input/event4>, buf: 0x560c01bb8240, count: 8112) = 48
           0.029 ( 0.001 ms): gnome-shell/1663 read(fd: 24</dev/input/event4>, buf: 0x560c01bb8258, count: 8088) = -1 EAGAIN Resource temporarily unavailable
           0.032 ( 0.001 ms): gnome-shell/1663 read(fd: 24</dev/input/event4>, buf: 0x560c01bb8240, count: 8112) = -1 EAGAIN Resource temporarily unavailable
           0.040 ( 0.003 ms): gnome-shell/1663 recvmsg(fd: 46<socket:[35893]>, msg: 0x7ffd8f3ef950) = -1 EAGAIN Resource temporarily unavailable
          21.529 ( 0.002 ms): gnome-shell/1663 epoll_pwait(epfd: 5<anon_inode:[eventpoll]>, events: 0x7ffd8f3ef960, maxevents: 32, sigsetsize: 8) = 1
          21.533 ( 0.004 ms): gnome-shell/1663 recvmsg(fd: 82<socket:[42826]>, msg: 0x7ffd8f3ef7b0, flags: DONTWAIT|CMSG_CLOEXEC) = 236
          21.581 ( 0.006 ms): gnome-shell/1663 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_BUSY, arg: 0x7ffd8f3ef060) = 0
          21.605 ( 0.020 ms): gnome-shell/1663 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_CREATE, arg: 0x7ffd8f3eeea0) = 0
          21.626 ( 0.119 ms): gnome-shell/1663 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_SET_DOMAIN, arg: 0x7ffd8f3eee94) = 0
          21.746 ( 0.081 ms): gnome-shell/1663 ioctl(fd: 8</dev/dri/card0>, cmd: DRM_I915_GEM_PWRITE, arg: 0x7ffd8f3eeea0) = 0
        ^C
      
      Oops, yet another gnome process that is involved with the output that
      'perf trace' generates, lets filter that out too:
      
        # perf trace --filter-pids 2469,1663 -e tools/perf/examples/bpf/augmented_raw_syscalls.c
               ? (         ): wpa_supplicant/1366  ... [continued]: select()) = 0 Timeout
           0.006 ( 0.002 ms): wpa_supplicant/1366 clock_gettime(which_clock: BOOTTIME, tp: 0x7fffe5b1e430) = 0
           0.011 ( 0.001 ms): wpa_supplicant/1366 clock_gettime(which_clock: BOOTTIME, tp: 0x7fffe5b1e3e0) = 0
           0.014 ( 0.001 ms): wpa_supplicant/1366 clock_gettime(which_clock: BOOTTIME, tp: 0x7fffe5b1e430) = 0
               ? (         ): gmain/1791  ... [continued]: poll()) = 0 Timeout
           0.017 (         ): wpa_supplicant/1366 select(n: 6, inp: 0x55646fed3ad0, outp: 0x55646fed3b60, exp: 0x55646fed3bf0, tvp: 0x7fffe5b1e4a0) ...
         157.879 ( 0.019 ms): gmain/1791 inotify_add_watch(fd: 8<anon_inode:inotify>, pathname: , mask: 16789454) = -1 ENOENT No such file or directory
               ? (         ): cupsd/1001  ... [continued]: epoll_pwait()) = 0
               ? (         ): gsd-color/1908  ... [continued]: poll()) = 0 Timeout
         499.615 (         ): cupsd/1001 epoll_pwait(epfd: 4<anon_inode:[eventpoll]>, events: 0x557a21166500, maxevents: 4096, timeout: 1000, sigsetsize: 8) ...
         586.593 ( 0.004 ms): gsd-color/1908 recvmsg(fd: 3<socket:[38074]>, msg: 0x7ffdef34e800) = -1 EAGAIN Resource temporarily unavailable
               ? (         ): fwupd/2230  ... [continued]: poll()) = 0 Timeout
               ? (         ): rtkit-daemon/906  ... [continued]: poll()) = 0 Timeout
               ? (         ): rtkit-daemon/907  ... [continued]: poll()) = 1
         724.603 ( 0.007 ms): rtkit-daemon/907 read(fd: 6<anon_inode:[eventfd]>, buf: 0x7f05ff768d08, count: 8) = 8
               ? (         ): ssh/5461  ... [continued]: select()) = 1
         810.431 ( 0.002 ms): ssh/5461 clock_gettime(which_clock: BOOTTIME, tp: 0x7ffd7f39f870) = 0
         ^C
      
      Several syscall exit events for syscalls in flight when 'perf trace' started, etc. Saner :-)
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-c3tu5yg204p5mvr9kvwew07n@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      e312747b
    • A
      perf trace: Fill in BPF "filtered_pids" map when present · a9964c43
      Arnaldo Carvalho de Melo 提交于
      This makes the augmented_syscalls support the --filter-pids and
      auto-filtered feedback loop pids just like when working without BPF,
      i.e. with just raw_syscalls:sys_{enter,exit} and tracepoint filters.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-zc5n453sxxm0tz1zfwwelyti@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      a9964c43
    • A
      perf trace: See if there is a map named "filtered_pids" · 744fafc7
      Arnaldo Carvalho de Melo 提交于
      Lookup for the first map named "filtered_pids" and, if augmenting
      syscalls, i.e. if a BPF event is present and the
      "__augmented_syscalls__" is present, then fill in that map with the pids
      to filter, be it feedback loop ones (perf trace's pid, its father if it
      is "sshd", more auto-filtered in the future) or the ones explicitely
      stated in the tool command line via --filter-pids.
      
      The code to actually fill in the map comes next.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-rhzytmw7qpe6lqyjxi1ded9t@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      744fafc7
    • A
      perf trace: Add "_from_option" suffix to trace__set_filter() · 6a0b3aba
      Arnaldo Carvalho de Melo 提交于
      As we'll need that name for a new function to set filters for both
      tracepoints and BPF maps for filtering pids.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-mdkck6hf3fnd21rz2766280q@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      6a0b3aba
    • A
      perf evlist: Rename perf_evlist__set_filter* to perf_evlist__set_tp_filter* · 7ad92a33
      Arnaldo Carvalho de Melo 提交于
      To better reflect that this is a tracepoint filter, as opposed, for
      instance to map based BPF filters.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-9138svli6ddcphrr3ymy9oy3@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      7ad92a33
    • A
      perf augmented_syscalls: Use pid_filter · ed9a77ba
      Arnaldo Carvalho de Melo 提交于
      Just to test filtering a bunch of pids, now its time to go and get that
      hooked up in 'perf trace', right after we load the bpf program, if we
      find a "pids_filtered" map defined, we'll populate it with the filtered
      pids.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-1i9s27wqqdhafk3fappow84x@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      ed9a77ba
    • A
      perf augmented_syscalls: Drop 'write', 'poll' for testing without self pid filter · 77ecb640
      Arnaldo Carvalho de Melo 提交于
      When testing system wide tracing without filtering the syscalls called
      by 'perf trace' itself we get into a feedback loop, drop for now those
      two syscalls, that are the ones that 'perf trace' does in its loop for
      writing the syscalls it intercepts, to help with testing till we get
      that filtering in place.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-rkbu536af66dbsfx51sr8yof@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      77ecb640
    • A
      perf bpf: Add simple pid_filter class accessible to BPF proggies · 8008aab0
      Arnaldo Carvalho de Melo 提交于
      Will be used in the augmented_raw_syscalls.c to implement 'perf trace
      --filter-pids'.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-9sybmz4vchlbpqwx2am13h9e@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      8008aab0
    • A
      perf bpf: Add defines for map insertion/lookup · 382b55db
      Arnaldo Carvalho de Melo 提交于
      Starting with a helper for a basic pid_map(), a hash using a pid as a
      key.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-gdwvq53wltvq6b3g5tdmh0cw@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      382b55db
    • A
      perf augmented_syscalls: Remove needless linux/socket.h include · 66067538
      Arnaldo Carvalho de Melo 提交于
      Leftover from when we started augmented_raw_syscalls.c from
      tools/perf/examples/bpf/augmented_syscalls.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Fixes: e58a0322dbac ("perf examples bpf: Start augmenting raw_syscalls:sys_{start,exit}")
      Link: https://lkml.kernel.org/n/tip-pmts9ls2skh8n3zisb4txudd@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      66067538
    • A
      perf augmented_syscalls: Filter on a hard coded pid · 55f127b4
      Arnaldo Carvalho de Melo 提交于
      Just to show where we'll hook pid based filters, and what we use to
      obtain the current pid, using a BPF getpid() equivalent.
      
      Now we need to remove that hardcoded PID with a BPF hash map, so that we
      start by filtering 'perf trace's own PID, implement the --filter-pid
      functionality, etc.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-oshrcgcekiyhd0whwisxfvtv@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      55f127b4
    • A
      perf bpf: Add unistd.h to the headers accessible to bpf proggies · 1475d35c
      Arnaldo Carvalho de Melo 提交于
      Start with a getpid() function wrapping BPF_FUNC_get_current_pid_tgid,
      idea is to mimic the system headers.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-zo8hv22onidep7tm785dzxfk@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      1475d35c
  2. 20 11月, 2018 3 次提交
  3. 13 11月, 2018 1 次提交
  4. 06 11月, 2018 13 次提交
  5. 05 11月, 2018 1 次提交
    • A
      perf augmented_syscalls: Start collecting pathnames in the BPF program · 79ef68c7
      Arnaldo Carvalho de Melo 提交于
      This is the start of having the raw_syscalls:sys_enter BPF handler
      collecting pointer arguments, namely pathnames, and with two syscalls
      that have that pointer in different arguments, "open" as it as its first
      argument, "openat" as the second.
      
      With this in place the existing beautifiers in 'perf trace' works, those
      args are shown instead of just the pointer that comes with the syscalls
      tracepoints.
      
      This also serves to show and document pitfalls in the process of using
      just that place in the kernel (raw_syscalls:sys_enter) plus tables
      provided by userspace to collect syscall pointer arguments.
      
      One is the need to use a barrier, as suggested by Edward, to avoid clang
      optimizations that make the kernel BPF verifier to refuse loading our
      pointer contents collector.
      
      The end result should be a generic eBPF program that works in all
      architectures, with the differences amongst archs resolved by the
      userspace component, 'perf trace', that should get all its tables
      created automatically from the kernel components where they are defined,
      via string table constructors for things not expressed in BTF/DWARF
      (enums, structs, etc), and otherwise using those observability files
      (BTF).
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: Alexei Starovoitov <ast@kernel.org>
      Cc: Daniel Borkmann <daniel@iogearbox.net>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Edward Cree <ecree@solarflare.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Martin KaFai Lau <kafai@fb.com>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Cc: Yonghong Song <yhs@fb.com>
      Link: https://lkml.kernel.org/n/tip-37dz54pmotgpnwg9tb6zuk9j@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      79ef68c7
  6. 03 11月, 2018 1 次提交
    • A
      perf trace: Fix setting of augmented payload when using eBPF + raw_syscalls · cd26ea6d
      Arnaldo Carvalho de Melo 提交于
      For now with BPF raw_augmented we hook into raw_syscalls:sys_enter and
      there we get all 6 syscall args plus the tracepoint common fields
      (sizeof(long)) and the syscall_nr (another long). So we check if that is
      the case and if so don't look after the sc->args_size, but always after
      the full raw_syscalls:sys_enter payload, which is fixed.
      
      We'll revisit this later to pass s->args_size to the BPF augmenter (now
      tools/perf/examples/bpf/augmented_raw_syscalls.c, so that it copies only
      what we need for each syscall, like what happens when we use
      syscalls:sys_enter_NAME, so that we reduce the kernel/userspace traffic
      to just what is needed for each syscall.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-nlslrg8apxdsobt4pwl3n7ur@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      cd26ea6d
  7. 02 11月, 2018 2 次提交
    • A
      perf trace: When augmenting raw_syscalls plug raw_syscalls:sys_exit too · 3c5e3dab
      Arnaldo Carvalho de Melo 提交于
      With just this commit we get to support all syscalls via hooking
      raw_syscalls:sys_{enter,exit} to the trace__sys_{enter,exit} routines
      to combine, strace-like, those tracepoints.
      
        # trace -e tools/perf/examples/bpf/augmented_raw_syscalls.c sleep 1
               ? (         ): sleep/31680  ... [continued]: execve()) = 0
           0.043 ( 0.004 ms): sleep/31680 brk() = 0x55652a851000
           0.070 ( 0.009 ms): sleep/31680 access(filename:, mode: R) = -1 ENOENT No such file or directory
           0.087 ( 0.006 ms): sleep/31680 openat(dfd: CWD, filename: , flags: CLOEXEC) = 3
           0.096 ( 0.003 ms): sleep/31680 fstat(fd: 3, statbuf: 0x7ffc5269e190) = 0
           0.101 ( 0.005 ms): sleep/31680 mmap(len: 103334, prot: READ, flags: PRIVATE, fd: 3) = 0x7f709c239000
           0.109 ( 0.002 ms): sleep/31680 close(fd: 3) = 0
           0.126 ( 0.006 ms): sleep/31680 openat(dfd: CWD, filename: , flags: CLOEXEC) = 3
           0.135 ( 0.003 ms): sleep/31680 read(fd: 3, buf: 0x7ffc5269e358, count: 832) = 832
           0.141 ( 0.002 ms): sleep/31680 fstat(fd: 3, statbuf: 0x7ffc5269e1f0) = 0
           0.146 ( 0.005 ms): sleep/31680 mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS) = 0x7f709c237000
           0.159 ( 0.007 ms): sleep/31680 mmap(len: 3889792, prot: EXEC|READ, flags: PRIVATE|DENYWRITE, fd: 3) = 0x7f709bc79000
           0.168 ( 0.009 ms): sleep/31680 mprotect(start: 0x7f709be26000, len: 2093056) = 0
           0.179 ( 0.010 ms): sleep/31680 mmap(addr: 0x7f709c025000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 1753088) = 0x7f709c025000
           0.196 ( 0.005 ms): sleep/31680 mmap(addr: 0x7f709c02b000, len: 14976, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) = 0x7f709c02b000
           0.210 ( 0.002 ms): sleep/31680 close(fd: 3) = 0
           0.230 ( 0.002 ms): sleep/31680 arch_prctl(option: 4098, arg2: 140121632638208) = 0
           0.306 ( 0.009 ms): sleep/31680 mprotect(start: 0x7f709c025000, len: 16384, prot: READ) = 0
           0.338 ( 0.005 ms): sleep/31680 mprotect(start: 0x556529607000, len: 4096, prot: READ) = 0
           0.348 ( 0.005 ms): sleep/31680 mprotect(start: 0x7f709c253000, len: 4096, prot: READ) = 0
           0.356 ( 0.019 ms): sleep/31680 munmap(addr: 0x7f709c239000, len: 103334) = 0
           0.463 ( 0.002 ms): sleep/31680 brk() = 0x55652a851000
           0.468 ( 0.004 ms): sleep/31680 brk(brk: 0x55652a872000) = 0x55652a872000
           0.474 ( 0.002 ms): sleep/31680 brk() = 0x55652a872000
           0.484 ( 0.008 ms): sleep/31680 open(filename: , flags: CLOEXEC) = 3
           0.497 ( 0.002 ms): sleep/31680 fstat(fd: 3, statbuf: 0x7f709c02aaa0) = 0
           0.501 ( 0.006 ms): sleep/31680 mmap(len: 113045344, prot: READ, flags: PRIVATE, fd: 3) = 0x7f70950aa000
           0.514 ( 0.002 ms): sleep/31680 close(fd: 3) = 0
           0.554 (1000.140 ms): sleep/31680 nanosleep(rqtp: 0x7ffc5269eed0) = 0
        1000.734 ( 0.007 ms): sleep/31680 close(fd: 1) = 0
        1000.748 ( 0.004 ms): sleep/31680 close(fd: 2) = 0
        1000.769 (         ): sleep/31680 exit_group()
        #
      
      Now to allow selecting which syscalls should be traced, using a map.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-votqqmqhag8e1i9mgyzfez3o@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      3c5e3dab
    • A
      perf examples bpf: Start augmenting raw_syscalls:sys_{start,exit} · febf8a37
      Arnaldo Carvalho de Melo 提交于
      The previous approach of attaching to each syscall showed how it is
      possible to augment tracepoints and use that augmentation, pointer
      payloads, in the existing beautifiers in 'perf trace', but for a more
      general solution we now will try to augment the main
      raw_syscalls:sys_{enter,exit} syscalls, and then pass instructions in
      maps so that it knows which syscalls and which pointer contents, and how
      many bytes for each of the arguments should be copied.
      
      Start with just the bare minimum to collect what is provided by those
      two tracepoints via the __augmented_syscalls__ map + bpf-output perf
      event, which results in perf trace showing them without connecting
      enter+exit:
      
        # perf trace -e tools/perf/examples/bpf/augmented_raw_syscalls.c sleep 1
           0.000 sleep/11563 raw_syscalls:sys_exit:NR 59 = 0
           0.019 (         ): sleep/11563 brk() ...
           0.021 sleep/11563 raw_syscalls:sys_exit:NR 12 = 94682642325504
           0.033 (         ): sleep/11563 access(filename:, mode: R) ...
           0.037 sleep/11563 raw_syscalls:sys_exit:NR 21 = -2
           0.041 (         ): sleep/11563 openat(dfd: CWD, filename: , flags: CLOEXEC) ...
           0.044 sleep/11563 raw_syscalls:sys_exit:NR 257 = 3
           0.045 (         ): sleep/11563 fstat(fd: 3, statbuf: 0x7ffdbf7119b0) ...
           0.046 sleep/11563 raw_syscalls:sys_exit:NR 5 = 0
           0.047 (         ): sleep/11563 mmap(len: 103334, prot: READ, flags: PRIVATE, fd: 3) ...
           0.049 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196285493248
           0.050 (         ): sleep/11563 close(fd: 3) ...
           0.051 sleep/11563 raw_syscalls:sys_exit:NR 3 = 0
           0.059 (         ): sleep/11563 openat(dfd: CWD, filename: , flags: CLOEXEC) ...
           0.062 sleep/11563 raw_syscalls:sys_exit:NR 257 = 3
           0.063 (         ): sleep/11563 read(fd: 3, buf: 0x7ffdbf711b78, count: 832) ...
           0.065 sleep/11563 raw_syscalls:sys_exit:NR 0 = 832
           0.066 (         ): sleep/11563 fstat(fd: 3, statbuf: 0x7ffdbf711a10) ...
           0.067 sleep/11563 raw_syscalls:sys_exit:NR 5 = 0
           0.068 (         ): sleep/11563 mmap(len: 8192, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS) ...
           0.070 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196285485056
           0.073 (         ): sleep/11563 mmap(len: 3889792, prot: EXEC|READ, flags: PRIVATE|DENYWRITE, fd: 3) ...
           0.076 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196279463936
           0.077 (         ): sleep/11563 mprotect(start: 0x7f81fd8a8000, len: 2093056) ...
           0.083 sleep/11563 raw_syscalls:sys_exit:NR 10 = 0
           0.084 (         ): sleep/11563 mmap(addr: 0x7f81fdaa7000, len: 24576, prot: READ|WRITE, flags: PRIVATE|FIXED|DENYWRITE, fd: 3, off: 1753088) ...
           0.088 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196283314176
           0.091 (         ): sleep/11563 mmap(addr: 0x7f81fdaad000, len: 14976, prot: READ|WRITE, flags: PRIVATE|FIXED|ANONYMOUS) ...
           0.093 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196283338752
           0.097 (         ): sleep/11563 close(fd: 3) ...
           0.098 sleep/11563 raw_syscalls:sys_exit:NR 3 = 0
           0.107 (         ): sleep/11563 arch_prctl(option: 4098, arg2: 140196285490432) ...
           0.108 sleep/11563 raw_syscalls:sys_exit:NR 158 = 0
           0.143 (         ): sleep/11563 mprotect(start: 0x7f81fdaa7000, len: 16384, prot: READ) ...
           0.146 sleep/11563 raw_syscalls:sys_exit:NR 10 = 0
           0.157 (         ): sleep/11563 mprotect(start: 0x561d037e7000, len: 4096, prot: READ) ...
           0.160 sleep/11563 raw_syscalls:sys_exit:NR 10 = 0
           0.163 (         ): sleep/11563 mprotect(start: 0x7f81fdcd5000, len: 4096, prot: READ) ...
           0.165 sleep/11563 raw_syscalls:sys_exit:NR 10 = 0
           0.166 (         ): sleep/11563 munmap(addr: 0x7f81fdcbb000, len: 103334) ...
           0.174 sleep/11563 raw_syscalls:sys_exit:NR 11 = 0
           0.216 (         ): sleep/11563 brk() ...
           0.217 sleep/11563 raw_syscalls:sys_exit:NR 12 = 94682642325504
           0.217 (         ): sleep/11563 brk(brk: 0x561d05453000) ...
           0.219 sleep/11563 raw_syscalls:sys_exit:NR 12 = 94682642460672
           0.220 (         ): sleep/11563 brk() ...
           0.221 sleep/11563 raw_syscalls:sys_exit:NR 12 = 94682642460672
           0.224 (         ): sleep/11563 open(filename: , flags: CLOEXEC) ...
           0.228 sleep/11563 raw_syscalls:sys_exit:NR 2 = 3
           0.229 (         ): sleep/11563 fstat(fd: 3, statbuf: 0x7f81fdaacaa0) ...
           0.230 sleep/11563 raw_syscalls:sys_exit:NR 5 = 0
           0.231 (         ): sleep/11563 mmap(len: 113045344, prot: READ, flags: PRIVATE, fd: 3) ...
           0.234 sleep/11563 raw_syscalls:sys_exit:NR 9 = 140196166418432
           0.237 (         ): sleep/11563 close(fd: 3) ...
           0.238 sleep/11563 raw_syscalls:sys_exit:NR 3 = 0
           0.262 (         ): sleep/11563 nanosleep(rqtp: 0x7ffdbf7126f0) ...
        1000.399 sleep/11563 raw_syscalls:sys_exit:NR 35 = 0
        1000.440 (         ): sleep/11563 close(fd: 1) ...
        1000.447 sleep/11563 raw_syscalls:sys_exit:NR 3 = 0
        1000.454 (         ): sleep/11563 close(fd: 2) ...
        1000.468 (         ): sleep/11563 exit_group(                                                           )
        #
      
      In the next csets we'll connect those events to the existing enter/exit
      raw_syscalls handlers in 'perf trace', just like we did with the
      syscalls:sys_{enter,exit}_* tracepoints.
      
      Cc: Adrian Hunter <adrian.hunter@intel.com>
      Cc: David Ahern <dsahern@gmail.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Wang Nan <wangnan0@huawei.com>
      Link: https://lkml.kernel.org/n/tip-5nl8l4hx1tl9pqdx65nkp6pw@git.kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
      febf8a37
  8. 31 10月, 2018 6 次提交