Re: [PATCH 1/5] core: Add method to get the vmlinux BTF filename, allow overriding it via env var

Arnaldo Carvalho de Melo
2024-11-19T18:32:10Z

On Tue, Nov 19, 2024 at 10:24:14AM -0800, Eduard Zingerman wrote:
> On Mon, 2024-11-18 at 17:41 -0300, Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <acme@redhat.com>
> >
> > In systems where BTF isn't available there were reports that the
> > simplest pahole call, without any args, segfaults.
> >
> > To have a proper test before fixing this problem, allow overriding the
> > /sys/kernel/btf/vmlinux filename, so that even in systems with BTF we an
> > point it to a invalid location, making pahole think that there is no BTF
> > available and thus fallback to something that currently segfaults.
> >
> > Using it:
> >
> > $ pahole list_head
> > struct list_head {
> > struct list_head * next; /* 0 8 */
> > struct list_head * prev; /* 8 8 */
> >
> > /* size: 16, cachelines: 1, members: 2 */
> > /* last cacheline: 16 bytes */
> > };
> > $
> > $ PAHOLE_VMLINUX_BTF_FILENAME=foobar pahole list_head
> > Segmentation fault (core dumped)
> > $
> >
> > Reported-by: Matthias Schwarzott <zzam@gentoo.org>
> > Cc: Alan Maguire <alan.maguire@oracle.com>
> > Cc: Andrii Nakryiko <andrii@kernel.org>
> > Cc: Eduard Zingerman <eddyz87@gmail.com>
> > Cc: Jiri Olsa <jolsa@kernel.org>
> > Cc: Song Liu <song@kernel.org>
> > Cc: Yonghong Song <yonghong.song@linux.dev>
> > Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
> > ---
>
> Lgtm, tried setting PAHOLE_VMLINUX_BTF_FILENAME to unrelated selftests
> with some BTF, pahole works as expected (prints structures defined in
> the selftest).
>
> Tested-by: Eduard Zingerman <eddyz87@gmail.com>

Thanks a lot, added to the cset!

- Arnaldo

> …