From: bot+bpf-ci@kernel.org
To: sidnayyar@google.com,andrii@kernel.org,eddyz87@gmail.com,ast@kernel.org,daniel@iogearbox.net,martin.lau@linux.dev,memxor@gmail.com,song@kernel.org,yonghong.song@linux.dev,jolsa@kernel.org
Cc: bpf@vger.kernel.org,linux-kernel@vger.kernel.org,gprocida@google.com,maennich@google.com,sidnayyar@google.com,ast@kernel.org,andrii@kernel.org,daniel@iogearbox.net,martin.lau@kernel.org,eddyz87@gmail.com,yonghong.song@linux.dev,clm@meta.com,ihor.solodrai@linux.dev
Subject: Re: [PATCH v3 1/3] libbpf: load vmlinux BTF in gen_loader mode for struct_ops
Date: Tue, 26 May 2026 14:54:40 +0000 (UTC) [thread overview]
Message-ID: <20696e4e019ea87f2179fbd1a1af423c9591708e0a31ceebe61d181ff6f8cf52@mail.kernel.org> (raw)
In-Reply-To: <20260526-libbpf-load-vmlinux-btf-in-gen_loader-mode-v3-1-5b4fa2a5e1a4@google.com>
[-- Attachment #1: Type: text/plain, Size: 2634 bytes --]
> libbpf: load vmlinux BTF in gen_loader mode for struct_ops
>
> During light skeleton generation (`bpftool gen skeleton -L`), libbpf
> runs in gen_loader mode. Previously, `bpf_object__load_vmlinux_btf()`
> completely bypassed loading the kernel vmlinux BTF (`obj->btf_vmlinux`)
> if `gen_loader` was active.
>
> However, BPF `struct_ops` maps (such as `sched_ext_ops` maps) require
> resolving the kernel-side struct type IDs and member sizes at
> compile/skeleton generation time. Without loading `btf_vmlinux`, libbpf
> cannot query the kernel BTF types, causing light skeleton generation for
> `struct_ops` to fail or omit crucial type information.
>
> Fix this by modifying the check to load `btf_vmlinux` even in
> `gen_loader` mode if the BPF object actually requires kernel vmlinux BTF
> (e.g. contains `struct_ops` maps).
>
> Signed-off-by: Siddharth Nayyar <sidnayyar@google.com>
This looks like a bug fix for commit 67234743736a which introduced the
gen_loader functionality. Should this include:
Fixes: 67234743736a ("libbpf: Generate loader program out of BPF ELF file.")
> diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c
> index ab2071fdd3e8..6163e53a2056 100644
> --- a/tools/lib/bpf/libbpf.c
> +++ b/tools/lib/bpf/libbpf.c
> @@ -3590,7 +3590,10 @@ static int bpf_object__load_vmlinux_btf(struct bpf_object *obj, bool force)
> int err;
>
> /* btf_vmlinux could be loaded earlier */
> - if (obj->btf_vmlinux || obj->gen_loader)
> + if (obj->btf_vmlinux)
> + return 0;
> +
> + if (obj->gen_loader && !obj_needs_vmlinux_btf(obj))
> return 0;
>
> if (!force && !obj_needs_vmlinux_btf(obj))
Does this change provide a complete solution for struct_ops support in
light skeleton mode? In the earlier review thread, Alexei Starovoitov
commented:
"That's a step, but please provide an end-to-end solution where
struct-ops and sched-ext programs are supported in lksel mode. This
step alone may be more confusing to users than helpful."
The author responded by expanding this to a 3-patch series in v2/v3.
However, only this first patch is present here. The other patches in
that series were:
- Patch 2/3: Zeroing btf_key_type_id
- Patch 3/3: Plumbing btf_vmlinux_value_type_id in gen_loader
Without those additional changes, will struct_ops maps actually work in
light skeleton generation, or does this incomplete series leave the
feature partially broken?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/26454419965
next prev parent reply other threads:[~2026-05-26 14:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-26 14:15 [PATCH v3 0/3] libbpf: support STRUCT_OPS in light skeletons Siddharth Nayyar
2026-05-26 14:15 ` [PATCH v3 1/3] libbpf: load vmlinux BTF in gen_loader mode for struct_ops Siddharth Nayyar
2026-05-26 14:54 ` bot+bpf-ci [this message]
2026-05-26 14:15 ` [PATCH v3 2/3] libbpf: zero out btf_key_type_id for STRUCT_OPS maps Siddharth Nayyar
2026-05-26 14:54 ` bot+bpf-ci
2026-05-26 14:15 ` [PATCH v3 3/3] libbpf: plumb btf_vmlinux_value_type_id and btf_fd in gen_loader Siddharth Nayyar
2026-05-26 14:54 ` bot+bpf-ci
2026-05-26 14:49 ` [PATCH v3 0/3] libbpf: support STRUCT_OPS in light skeletons Alexei Starovoitov
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=20696e4e019ea87f2179fbd1a1af423c9591708e0a31ceebe61d181ff6f8cf52@mail.kernel.org \
--to=bot+bpf-ci@kernel.org \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=clm@meta.com \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=gprocida@google.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maennich@google.com \
--cc=martin.lau@kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=sidnayyar@google.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®