iovisor / bcc

BCC - Tools for BPF-based Linux IO analysis, networking, monitoring, and more
Apache License 2.0
20.34k stars 3.86k forks source link

libbpf-tools: memleak tools fails to build on ppc64 #4547

Open jeromemarchand opened 1 year ago

jeromemarchand commented 1 year ago

The libpf tool memleak fails to build on powerpc 64 with the following error:

  BPF      memleak.bpf.o
memleak.bpf.c:377:23: error: no member named 'bytes_alloc' in 'struct trace_event_raw_percpu_alloc_percpu'
        gen_alloc_enter(ctx->bytes_alloc);
                        ~~~  ^
1 error generated.
make: *** [Makefile:198: /builddir/build/BUILD/bcc-0.27.0/libbpf-tools/.output/memleak.bpf.o] Error 1

The field bytes_alloc is indeed missing from trace_event_raw_percpu_alloc_percpu in powerpc vmlinux.h. I don't see what makes ppc64 different than other arches here.

bcc version: 0.27.0 Kernel version: 6.2.8-200.fc37.ppc64le

chenhengqi commented 1 year ago

This is because the bytes_alloc field is introduced in kernel 5.19, see https://github.com/torvalds/linux/commit/f67bed134a053663852a1a3ab1b3223bfc2104a2.

Update powerpc vmlinux.h on latest kernel should fix the build failure. But we also need a CO-RE fix to get it run on old kernels.

jeromemarchand commented 1 year ago

I wonder: shouldn't there be an option to automatically generate vmlinux.h from the running kernel?

chenhengqi commented 1 year ago

I wonder: shouldn't there be an option to automatically generate vmlinux.h from the running kernel?

This does not solve the problem actually.

michael-chuh commented 1 year ago

I think alloc size of percpu is always cared, not the total size 'ctx->bytes_alloc' So use 'ctx->size' wolud be better like bcc tools https://github.com/iovisor/bcc/blob/master/tools/memleak.py#L401