Re: [PATCH v3 bpf-next 10/10] bpftool: Show probed function in perf_event link info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Jun 12, 2023 at 8:16 AM Yafang Shao <laoar.shao@xxxxxxxxx> wrote:
>
> Enhance bpftool to display comprehensive information about exposed
> perf_event links, covering uprobe, kprobe, tracepoint, and generic perf
> event. The resulting output will include the following details:
>
> $ tools/bpf/bpftool/bpftool link show
> 3: perf_event  prog 14
>         event_type software  event_config cpu-clock
>         bpf_cookie 0
>         pids perf_event(1379330)
> 4: perf_event  prog 14
>         event_type hw-cache  event_config LLC-load-misses
>         bpf_cookie 0
>         pids perf_event(1379330)
> 5: perf_event  prog 14
>         event_type hardware  event_config cpu-cycles

how about

"event hardware:cpu-cycles" for events

>         bpf_cookie 0
>         pids perf_event(1379330)
> 6: perf_event  prog 20
>         retprobe 0  file_name /home/yafang/bpf/uprobe/a.out  offset 0x1338

for uprobes: "uprobe /home/yafang/bpf/uprobe/a.out+0x1338"
for retprobes: "uretprobe /home/yafang/bpf/uprobe/a.out+0x1338"

>         bpf_cookie 0
>         pids uprobe(1379706)
> 7: perf_event  prog 21
>         retprobe 1  file_name /home/yafang/bpf/uprobe/a.out  offset 0x1338
>         bpf_cookie 0
>         pids uprobe(1379706)
> 8: perf_event  prog 27
>         tp_name sched_switch

"tracepoint  sched_switch" ?

>         bpf_cookie 0
>         pids tracepoint(1381734)
> 10: perf_event  prog 43
>         retprobe 0  func_name kernel_clone  addr ffffffffad0a9660

similar to uprobes:

"kprobe kernel_clone  0xffffffffad0a9660"
"kretprobe kernel_clone  0xffffffffad0a9660"


That is, make this more human readable instead of mechanically
translated from kernel info? retprobe 1/0 is quite cumbersome,
"uprobe" vs "uretprobe" makes more sense?

JSON is where it could be completely mechanically translated, IMO.

>         bpf_cookie 0
>         pids kprobe(1384186)
> 11: perf_event  prog 41
>         retprobe 1  func_name kernel_clone  addr ffffffffad0a9660
>         bpf_cookie 0
>         pids kprobe(1384186)
>
> $ tools/bpf/bpftool/bpftool link show -j
> [{"id":3,"type":"perf_event","prog_id":14,"event_type":"software","event_config":"cpu-clock","bpf_cookie":0,"pids":[{"pid":1379330,"comm":"perf_event"}]},{"id":4,"type":"perf_event","prog_id":14,"event_type":"hw-cache","event_config":"LLC-load-misses","bpf_cookie":0,"pids":[{"pid":1379330,"comm":"perf_event"}]},{"id":5,"type":"perf_event","prog_id":14,"event_type":"hardware","event_config":"cpu-cycles","bpf_cookie":0,"pids":[{"pid":1379330,"comm":"perf_event"}]},{"id":6,"type":"perf_event","prog_id":20,"retprobe":0,"file_name":"/home/yafang/bpf/uprobe/a.out","offset":4920,"bpf_cookie":0,"pids":[{"pid":1379706,"comm":"uprobe"}]},{"id":7,"type":"perf_event","prog_id":21,"retprobe":1,"file_name":"/home/yafang/bpf/uprobe/a.out","offset":4920,"bpf_cookie":0,"pids":[{"pid":1379706,"comm":"uprobe"}]},{"id":8,"type":"perf_event","prog_id":27,"tp_name":"sched_switch","bpf_cookie":0,"pids":[{"pid":1381734,"comm":"tracepoint"}]},{"id":10,"type":"perf_event","prog_id":43,"retprobe":0,"func_name":"kernel_clone","offset":0,"addr":18446744072317736544,"bpf_cookie":0,"pids":[{"pid":1384186,"comm":"kprobe"}]},{"id":11,"type":"perf_event","prog_id":41,"retprobe":1,"func_name":"kernel_clone","offset":0,"addr":18446744072317736544,"bpf_cookie":0,"pids":[{"pid":1384186,"comm":"kprobe"}]}]
>
> For generic perf events, the displayed information in bpftool is limited to
> the type and configuration, while other attributes such as sample_period,
> sample_freq, etc., are not included.
>
> The kernel function address won't be exposed if it is not permitted by
> kptr_restrict. The result as follows when kptr_restrict is 2.
>
> $ tools/bpf/bpftool/bpftool link show
> 3: perf_event  prog 14
>         event_type software  event_config cpu-clock
> 4: perf_event  prog 14
>         event_type hw-cache  event_config LLC-load-misses
> 5: perf_event  prog 14
>         event_type hardware  event_config cpu-cycles
> 6: perf_event  prog 20
>         retprobe 0  file_name /home/yafang/bpf/uprobe/a.out  offset 0x1338
> 7: perf_event  prog 21
>         retprobe 1  file_name /home/yafang/bpf/uprobe/a.out  offset 0x1338
> 8: perf_event  prog 27
>         tp_name sched_switch
> 10: perf_event  prog 43
>         retprobe 0  func_name kernel_clone
> 11: perf_event  prog 41
>         retprobe 1  func_name kernel_clone
>
> Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx>
> ---
>  tools/bpf/bpftool/link.c | 213 +++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 213 insertions(+)
>

[...]





[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux