Re: [tip:timers/vdso 37/45] progs/hid_bpf_helpers.h:117:31: error: declaration of 'struct bpf_wq' will not be visible outside of this function

From: Benjamin Tissoires

Date: Thu Mar 12 2026 - 13:38:22 EST


On Mar 12 2026, Thomas Weißschuh wrote:
> Hi Benjamin,
>
> thanks for the quick response.
>
> On Wed, Mar 11, 2026 at 06:05:25PM +0100, Benjamin Tissoires wrote:
> > On Mar 11 2026, Thomas Wei�schuh wrote:
> > > could you take a look at the report below?
> > > This looks like an issue in the HID BPF subsystem, surfaced by my
> > > unrelated change. Does this ring a bell for you?
> > >
> > > I wasn't able to reproduce it so far, but will continue looking into it.
> >
> > Both struct bpf_wq and struct hid_device should be generated in the
> > vmlinux.h that we include in the selftests. So this is definitely not
> > related to your patch AFAICT.
>
> Ack. To be sure I sent this branch again through 0day and will see if it
> breaks on the same commit.
>
> > Looking in the config, we have `# CONFIG_HID_SUPPORT is not set` -> so
> > that would explain why struct hid_device is not available. But in that
> > case, why are the HID selftests even built?
>
> CONFIG_DEBUG_INFO_BTF is also not set. So there should be no vmlinux.h
> at all in the first. Which is exactly what happens in my attempts
> to reproduce the issue. But even when fixing that up, the issue persists.
>
> > The bpf_wq bits should be related to a similar-ish issue where one
> > config setting is not set and so it's not included in the final BTF.
>
> I'll look into how exactly things end up in vmlinux.h.
> At least the headers for 'struct bpf_wq' are always included somewhere.
> But maybe the type also needs to be used to define some structure.
>
> > I paged out how we can ignore selftests based on the .config, so if you
> > have any hints, that would be nice :)
>
> Inspecting the kernel configuration might be hard, as there might be no file
> for it available. Could you use vmlinux.h itself for feature detection?
>

Actually I think I remember the rationale:
- because working with config is hard, we just hide any struct
definition we need in progs/hid_bpf_helpers.h before including
vmlinux.h
- then we manually define them

So it looks like this is a step I forgot to make when I added the last
few bits: redefine struct bpf_wq and struct hid_device.

Technically we shouldn't even need to redefine the entire struct, but
only the bits we are accessing, because bpf with CO-RE will do the
offsets for us :)

Would the following patch fixes the issue?:
---