linux/tools
Yonghong Song b04df400c3 tools/bpftool: add perf subcommand
The new command "bpftool perf [show | list]" will traverse
all processes under /proc, and if any fd is associated
with a perf event, it will print out related perf event
information. Documentation is also added.

Below is an example to show the results using bcc commands.
Running the following 4 bcc commands:
  kprobe:     trace.py '__x64_sys_nanosleep'
  kretprobe:  trace.py 'r::__x64_sys_nanosleep'
  tracepoint: trace.py 't:syscalls:sys_enter_nanosleep'
  uprobe:     trace.py 'p:/home/yhs/a.out:main'

The bpftool command line and result:

  $ bpftool perf
  pid 21711  fd 5: prog_id 5  kprobe  func __x64_sys_write  offset 0
  pid 21765  fd 5: prog_id 7  kretprobe  func __x64_sys_nanosleep  offset 0
  pid 21767  fd 5: prog_id 8  tracepoint  sys_enter_nanosleep
  pid 21800  fd 5: prog_id 9  uprobe  filename /home/yhs/a.out  offset 1159

  $ bpftool -j perf
  [{"pid":21711,"fd":5,"prog_id":5,"fd_type":"kprobe","func":"__x64_sys_write","offset":0}, \
   {"pid":21765,"fd":5,"prog_id":7,"fd_type":"kretprobe","func":"__x64_sys_nanosleep","offset":0}, \
   {"pid":21767,"fd":5,"prog_id":8,"fd_type":"tracepoint","tracepoint":"sys_enter_nanosleep"}, \
   {"pid":21800,"fd":5,"prog_id":9,"fd_type":"uprobe","filename":"/home/yhs/a.out","offset":1159}]

  $ bpftool prog
  5: kprobe  name probe___x64_sys  tag e495a0c82f2c7a8d  gpl
	  loaded_at 2018-05-15T04:46:37-0700  uid 0
	  xlated 200B  not jited  memlock 4096B  map_ids 4
  7: kprobe  name probe___x64_sys  tag f2fdee479a503abf  gpl
	  loaded_at 2018-05-15T04:48:32-0700  uid 0
	  xlated 200B  not jited  memlock 4096B  map_ids 7
  8: tracepoint  name tracepoint__sys  tag 5390badef2395fcf  gpl
	  loaded_at 2018-05-15T04:48:48-0700  uid 0
	  xlated 200B  not jited  memlock 4096B  map_ids 8
  9: kprobe  name probe_main_1  tag 0a87bdc2e2953b6d  gpl
	  loaded_at 2018-05-15T04:49:52-0700  uid 0
	  xlated 200B  not jited  memlock 4096B  map_ids 9

  $ ps ax | grep "python ./trace.py"
  21711 pts/0    T      0:03 python ./trace.py __x64_sys_write
  21765 pts/0    S+     0:00 python ./trace.py r::__x64_sys_nanosleep
  21767 pts/2    S+     0:00 python ./trace.py t:syscalls:sys_enter_nanosleep
  21800 pts/3    S+     0:00 python ./trace.py p:/home/yhs/a.out:main
  22374 pts/1    S+     0:00 grep --color=auto python ./trace.py

Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
2018-05-24 18:18:20 -07:00
..
accounting
arch tools/headers: Synchronize kernel ABI headers, v4.17-rc1 2018-04-17 09:47:39 -03:00
bpf tools/bpftool: add perf subcommand 2018-05-24 18:18:20 -07:00
build Kbuild: fix # escaping in .cmd files for future Make 2018-04-11 00:03:02 +09:00
cgroup
firewire
gpio Linux 4.16-rc5 2018-03-18 17:48:59 +01:00
hv tools: hv: include string.h in hv_fcopy_daemon 2018-03-06 09:57:16 -08:00
iio
include tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf 2018-05-24 18:18:19 -07:00
kvm/kvm_stat tools/kvm_stat: Remove unused function 2018-03-28 22:47:06 +02:00
laptop
leds
lib tools/bpf: sync kernel header bpf.h and add bpf_task_fd_query in libbpf 2018-05-24 18:18:19 -07:00
memory-model tools/memory-model: Finish the removal of rb-dep, smp_read_barrier_depends(), and lockless_dereference() 2018-03-10 10:22:23 +01:00
nfsd
objtool objtool: Support HOSTCFLAGS and HOSTLDFLAGS 2018-04-17 07:59:42 +02:00
pci
pcmcia
perf perf stat: Fix duplicate PMU name for interval print 2018-04-24 16:12:00 -03:00
power tools: power/acpi, revert to LD = gcc 2018-05-04 11:24:22 +02:00
scripts Kbuild: fix # escaping in .cmd files for future Make 2018-04-11 00:03:02 +09:00
spi
testing tools/bpf: add two BPF_TASK_FD_QUERY tests in test_progs 2018-05-24 18:18:20 -07:00
thermal/tmon tools/thermal: tmon: fix for segfault 2018-03-27 09:51:23 +02:00
time
usb usbip: tools: usbipd: exclude exported devices from exportable device list 2018-03-22 13:08:20 +01:00
virtio ptr_ring: fix build 2018-03-20 03:17:37 +02:00
vm
wmi
Makefile