From: Alan Maguire <alan.maguire@oracle.com>
To: Ian Rogers <irogers@google.com>, bpf <bpf@vger.kernel.org>
Cc: linux-perf-users <linux-perf-users@vger.kernel.org>
Subject: Re: Better error message for kernels not compiled with BTF
Date: Tue, 23 Jan 2024 09:40:56 +0000 [thread overview]
Message-ID: <f4d8296d-dc7a-509e-aba3-741d22f889dd@oracle.com> (raw)
In-Reply-To: <CAP-5=fU+DN_+Y=Y4gtELUsJxKNDDCOvJzPHvjUVaUoeFAzNnig@mail.gmail.com>
On 23/01/2024 00:18, Ian Rogers wrote:
> Hi,
>
> if a kernel is compiled with CONFIG_DEBUG_INFO_BTF disabled then the
> libbpf fails on perf lock contention with:
> ```
> libbpf: failed to find valid kernel BTF
> libbpf: Error loading vmlinux BTF: -3
> libbpf: failed to load object 'lock_contention_bpf'
> libbpf: failed to load BPF skeleton 'lock_contention_bpf': -3
> Failed to load lock-contention BPF skeleton
> lock contention BPF setup failed
> ```
> The same error message is seen with BCC's libbpf-tools. I saw these
> messages on default Rapberry Pi OS that is derived from Debian (more
> context in https://bugzilla.kernel.org/show_bug.cgi?id=218401).
>
> Given that distributions are shipping perf and libbpf-tools that
> assume BTF is enabled, should CONFIG_DEBUG_INFO_BTF be enabled by
> default in the kernel?
>
That would be great, but if I remember one issue with this might be that
CONFIG_DEBUG_INFO_BTF depends on DEBUG_INFO (for the DWARF generation
that we construct BTF from), so I suspect enabling debug info by default
might be an issue. There has been discussion in the past about
supporting CONFIG_DEBUG_INFO_BTF in the non CONFIG_DEBUG_INFO case
(by temporarily generating DWARF then stripping it or similar).
What most distros usually do is strip the DWARF during packaging and
create debuginfo packages, but I imagine users who build kernels
themselves would want similar support if they were asking for
DEBUG_INFO_BTF but not DEBUG_INFO.
> Perhaps:
> ```
> libbpf: Error loading vmlinux BTF: -3
> ```
> Would be better as (especially if the user is root):
> ```
> libbpf: Error loading vmlinux BTF: -3 (was the kernel compiled with
> CONFIG_DEBUG_INFO_BTF?)
>
That would be great; one thing I think would really help users would be
to distinguish two cases in error messaging
1. /sys/kernel/btf/vmlinux is not there at all; for that case your above
error message is great (-ESRCH case)
2. /sys/kernel/btf/vmlinux is there, but can't be parsed, likely due to
it being built with newer BTF; the current libbpf being used to parse it
cannot read it (-EINVAL case). For this case something like ("BTF is
present, but cannot be read; it may be malformed, or the version of
libbpf reading it (%s) may be too old", version).
Having solution-oriented messaging for cases like this would really help
users I think. Thanks!
Alan
```
>
> Thanks,
> Ian
>
prev parent reply other threads:[~2024-01-23 9:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-23 0:18 Better error message for kernels not compiled with BTF Ian Rogers
2024-01-23 9:40 ` Alan Maguire [this message]
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=f4d8296d-dc7a-509e-aba3-741d22f889dd@oracle.com \
--to=alan.maguire@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=irogers@google.com \
--cc=linux-perf-users@vger.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