Re: [PATCH v2] percpu: do not put btf_type_tag on per-cpu variable declarations

From: Vineet Gupta

Date: Wed Dec 02 2026 - 15:04:22 EST


Hi,

Some comments below, mostly for Alexei; Andrew you can ignore ;-)

On 12/2/26 11:48 AM, Alexei Starovoitov wrote:
On Wed, Dec 02, 2026 at 11:03 AM Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> wrote:
On Tue, 17 Nov 2026 14:08:24 -0800 Vineet Gupta <vineet.gupta@xxxxxxxxx> wrote:

and GCC warns:

processor.h:232:36: warning: ignoring attributes applied to
'struct cpuinfo_x86' after definition [-Wattributes]

which -Werror turns into a build failure.
It's a prep for GCC support.

Sorry, I've been hiding from this patch because I don't understand the
BTF stuff at all :( Would it be more appropriate for a BPF person to
handle this?
The BPF side is fine.
It's really GCC behavior. clang does fine as-is.

Because clang ignores the construct GCC warns about.

It's arguable whether it's a gcc bug or correct behavior.
I feel the latter.

A GCC bug was opened PR/128480 [1] to silent the warning but was rejected won't fix, for the right reasons.

The issue is btf_type_tag being applied to a variant of an aggregate.

    struct mce { int status; };
    extern __attribute__((btf_type_tag("percpu")))
           __typeof__(struct mce) injectm;

    $ gcc -c t.c
    t.c:3:15: warning: ignoring attributes applied to 'struct mce' after definition [-Wattributes]

That warning is legit: In dwarf, every variant of an aggregate shares one DIE, so a btf_type_tag on such a variant has nowhere to live and is dropped. clang just does it silently, gcc complains.

Thx,
-Vineet

[1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=128480

otoh, Chris had a good look at the previous version so that and a few
weeks of -next exposure is enough.
I think it better fits in Nick's build tree, since it's about GCC
and less about bpf/btf.
But if folks are fine I can take it into bpf-next.