Re: [PATCH RFC bpf-next 0/7] bpf: Support struct_ops in light skeletons
From: Sid Nayyar
Date: Wed Nov 11 2026 - 02:40:54 EST
On Tue, Nov 10, 2026 at 6:43 PM Anton Protopopov <aspsk2@xxxxxxxxx> wrote:
>
> On Mon, Nov 9, 2026 at 10:40 PM Alexei Starovoitov
> <alexei.starovoitov@xxxxxxxxx> wrote:
> >
> > On Mon, Nov 09, 2026 at 11:46 AM Ihor Solodrai <ihor.solodrai@xxxxxxxxx> wrote:
> >
> > > Andrii, Alexei, wdyt? Any other ideas?
> >
> > The loader asks the kernel for ids, sizes and offsets only to pass them
> > back in the next three commands:
> >
> > the loader asks and passes it back in
> > -------------------------------- ------------------------------------
> > id, size of bpf_struct_ops_<t> BPF_MAP_CREATE
> > id of <t>, index of the member BPF_PROG_LOAD
> > offset of data, of every member BPF_MAP_UPDATE_ELEM
> >
> > the kernel can match by name instead.
> >
> > The kernel has both BTFs. BPF_MAP_CREATE of a struct_ops map demands
> > btf_fd of the object already, and bpf_struct_ops.c doesn't use it.
> > The kernel can find its struct_ops and the members by name,
> > like btf_parse_kptr() finds the type of a kptr.
> > Then the loader passes what bpftool knows when it generates
> > the skeleton:
> >
> > command the loader passes
> > ------------------- ---------------------------------------------------
> > BPF_MAP_CREATE btf_fd, btf_value_type_id and value_size of the
> > struct in the BTF of the object
> > BPF_PROG_LOAD attach_btf_obj_fd = btf_fd, attach_btf_id = that
> > struct, expected_attach_type = index of its member
> > BPF_MAP_UPDATE_ELEM that struct with the prog fds in it
> >
> > The kernel rejects such BPF_MAP_CREATE and BPF_PROG_LOAD today.
> > Nothing changes for existing users.
> > The BTF of the object is in the blob, so the signature covers the names.
> >
> > Then no need for a helper or a kfunc. The 4k buffer, the fds of module
> > BTF and the offsets at run time go away.
> > map->def.value_size, prog->attach_btf_id and prog->expected_attach_type
> > don't hold offsets into the blob.
> >
> > The diff below replaces patches 1-5. Patches 6 and 7 stay.
>
> I like Alexei's approach here, it fits with shirudo. I also have tested it.
> (Patches 6,7 weren't tested, shirudo uses libbpf without bpftool.)
>
Thank you Alexei, Ihor and Anton for the reviews.
I agree that the loader's efforts to find out ids, sizes and offsets
for STRUCT_OPS maps and its members is wasteful since it only passes
those values back to the kernel. I will redo my patch series using
Alexei's proposed approach and send it out for review as soon as
possible.
Regards,
Siddharth
> >
> > [...]
> >