From: Namhyung Kim <namhyung@kernel.org>
To: Tycho Andersen <tycho@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Ingo Molnar <mingo@redhat.com>,
Mark Rutland <mark.rutland@arm.com>,
Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Jiri Olsa <jolsa@kernel.org>, Ian Rogers <irogers@google.com>,
Adrian Hunter <adrian.hunter@intel.com>,
James Clark <james.clark@linaro.org>,
Chun-Tse Shao <ctshao@google.com>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Ravi Bangoria <ravi.bangoria@amd.com>,
K Prateek Nayak <kprateek.nayak@amd.com>
Subject: Re: [PATCH] perf: fix segfault in `lock contention -b`
Date: Tue, 13 Jan 2026 13:18:52 -0800 [thread overview]
Message-ID: <aWa2vDy_0QGh_a20@google.com> (raw)
In-Reply-To: <aWUeOQbFOZ2CVBG2@tycho.pizza>
On Mon, Jan 12, 2026 at 09:15:53AM -0700, Tycho Andersen wrote:
> On Fri, Jan 09, 2026 at 04:49:01PM -0800, Namhyung Kim wrote:
> > On Fri, Jan 09, 2026 at 09:44:17AM -0700, Tycho Andersen wrote:
> > > From: "Tycho Andersen (AMD)" <tycho@kernel.org>
> > >
> > > When run on a kernel without BTF info, I get:
> > >
> > > libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled?
> > > libbpf: failed to find valid kernel BTF
> > >
> > > Program received signal SIGSEGV, Segmentation fault.
> > > 0x00005555556915b7 in btf.type_cnt ()
> > > (gdb) bt
> > > #0 0x00005555556915b7 in btf.type_cnt ()
> > > #1 0x0000555555691fbc in btf_find_by_name_kind ()
> > > #2 0x00005555556920d0 in btf.find_by_name_kind ()
> > > #3 0x00005555558a1b7c in init_numa_data (con=0x7fffffffd0a0) at util/bpf_lock_contention.c:125
> > > #4 0x00005555558a264b in lock_contention_prepare (con=0x7fffffffd0a0) at util/bpf_lock_contention.c:313
> > > #5 0x0000555555620702 in __cmd_contention (argc=0, argv=0x7fffffffea10) at builtin-lock.c:2084
> > > #6 0x0000555555622c8d in cmd_lock (argc=0, argv=0x7fffffffea10) at builtin-lock.c:2755
> > > #7 0x0000555555651451 in run_builtin (p=0x555556104f00 <commands+576>, argc=3, argv=0x7fffffffea10)
> > > at perf.c:349
> > > #8 0x00005555556516ed in handle_internal_command (argc=3, argv=0x7fffffffea10) at perf.c:401
> > > #9 0x000055555565184e in run_argv (argcp=0x7fffffffe7fc, argv=0x7fffffffe7f0) at perf.c:445
> > > #10 0x0000555555651b9f in main (argc=3, argv=0x7fffffffea10) at perf.c:553
> > >
> > > If we really are running -b without BTF info, the error is fatal, so let's
> > > propagate it and exit accordingly.
> >
> > Thanks for the patch.
> >
> > I'm curious how the kernel will react if we want to load the BPF.
> > Probably the verifier will reject as it calls some helpers like
> > bpf_get_current_task_btf().
> >
> > I think it used to work without BTF - the callstack (default) and task
> > output mode won't need it. It'd be nice if we could run it when the
> > kernel doesn't have BTF. But maybe it's out of scope of this patch.
> >
> > That said, can you add a NULL check in the init_numa_data() instead
> > and see how far it can go?
>
> Looks like not much further, it fails in lock_contention_bpf__load():
>
> ./perf lock contention -b
> libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled?
> libbpf: failed to find valid kernel BTF
> libbpf: kernel BTF is missing at '/sys/kernel/btf/vmlinux', was CONFIG_DEBUG_INFO_BTF enabled?
> libbpf: failed to find valid kernel BTF
> libbpf: Error loading vmlinux BTF: -ESRCH
> libbpf: failed to load BPF skeleton 'lock_contention_bpf': -ESRCH
> Failed to load lock-contention BPF skeleton
> lock contention BPF setup failed
Thanks for checking this. I think it's ok to fail like this when BTF is
not enabled. Let me see if I can make some changes to run without it
later.
Thanks,
Namhyung
next prev parent reply other threads:[~2026-01-13 21:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-09 16:44 [PATCH] perf: fix segfault in `lock contention -b` Tycho Andersen
2026-01-10 0:49 ` Namhyung Kim
2026-01-12 16:15 ` Tycho Andersen
2026-01-13 21:18 ` Namhyung Kim [this message]
2026-02-04 15:20 ` Tycho Andersen
2026-02-04 21:26 ` Namhyung Kim
2026-01-13 3:11 ` K Prateek Nayak
2026-01-13 15:48 ` Tycho Andersen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aWa2vDy_0QGh_a20@google.com \
--to=namhyung@kernel.org \
--cc=acme@kernel.org \
--cc=adrian.hunter@intel.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=ctshao@google.com \
--cc=irogers@google.com \
--cc=james.clark@linaro.org \
--cc=jolsa@kernel.org \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=ravi.bangoria@amd.com \
--cc=tycho@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox