From: David <david@davidv.dev>
To: Viktor Malik <vmalik@redhat.com>, bpf@vger.kernel.org
Cc: Alan Maguire <alan.maguire@oracle.com>
Subject: Re: Usage of kfuncs in tracepoints
Date: Tue, 13 Jan 2026 12:53:18 +0100 [thread overview]
Message-ID: <b07a7008-a093-4a31-8096-1d5c33890c9d@davidv.dev> (raw)
In-Reply-To: <793831f1-a8ea-4e0b-a0e8-c86c30b1ab2f@redhat.com>
On 13/01/2026 09:05, Viktor Malik wrote:
> On 1/12/26 20:08, David wrote:
>> On 12/01/2026 19:03, Alan Maguire wrote:
>>
>>> I think you need to add "__ksym __weak";" here i.e.
>> This change let me load the program, however, libbpf cannot find a
>> kernel image at
>> /sys/kernel/btf/vmlinux, because /sys/kernel/btf is not populated on my
>> system.
>>
>> My kernel _is_ built with CONFIG_DEBUG_INFO_BTF=y, is there something
>> else I need to do
>> to get this path populated?
> Did you try rebuilding from scratch (with `make clean`) after enabling
> CONFIG_DEBUG_INFO_BTF? If the sources were already built without debug
> info, they will not be automatically rebuilt just by adding the config
> option.
>
I thought the change took place because `make vmlinux` took a while,
but after a clean build, it does work.
>> Because this path is missing, libbpf reports:
>>
>> ```
>> kernel BTF is missing at '/sys/kernel/btf/vmlinux', was
>> CONFIG_DEBUG_INFO_BTF enabled?
>> ```
>>
>> But I see from strace that it tries a few fallback paths.
>> In the meantime, I copied my kernel into /boot/vmlinux-6.18.2 so libbpf
>> can find it, but
>> now the loader says
>>
>> ```
>> calling kernel function is not supported without CONFIG_DEBUG_INFO_BTF
>> ```
> While libbpf may try other fallback paths to find BTF, using kfuncs
> requires the kernel to find that kfunc in BTF and kernel will only use
> the system BTF (the one from /sys/kernel/vmlinux/btf).
>
This is good to know, thanks. I've removed the /boot/ file from my system.
>> Can I not use `bpf_strstr` on a tracepoint? To validate, I tried a
>> `raw_tp` but
>> had the same result.
> There shouldn't be any issue using bpf_strstr from tracepoints (or any
> other program type).
>
> Viktor
>
Do you happen to know how to generate the kfunc headers with bpftool?
Even a new bpftool build from the newest commit,
ad5d76e5c6b622e5ed05fecfa68029bae949d408, does not generate headers:
```
$ ./bpftool btf dump file ~/git/linux-6.18.2/vmlinux | grep strstr
[28376] FUNC 'bpf_strstr' type_id=28354 linkage=static
[60023] FUNC 'strstr' type_id=60022 linkage=static
$ ./bpftool btf dump file ~/git/linux-6.18.2/vmlinux format c | grep -c
strstr
0
```
Could this be related to my host's kernel being older than 6.18?
For now, I'll generate my files from `kernel/bpf/helpers.c`, but it'd be
great if I could use bpftool.
David
next prev parent reply other threads:[~2026-01-13 11:53 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-12 16:57 Usage of kfuncs in tracepoints David
2026-01-12 18:03 ` Alan Maguire
2026-01-12 19:08 ` David
2026-01-13 8:05 ` Viktor Malik
2026-01-13 11:53 ` David [this message]
2026-01-13 12:08 ` Jiri Olsa
2026-01-13 13:58 ` David
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=b07a7008-a093-4a31-8096-1d5c33890c9d@davidv.dev \
--to=david@davidv.dev \
--cc=alan.maguire@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=vmalik@redhat.com \
/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