From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796238236; b=vmAmLDfXGNN//+7zGzGDdacRtvBFIyzJ4LaZAvq1gCstkLi3D9wzxRY3mFZI23QUYCAB x5e8bwbQl2IvORQjTixP0rqutnmN6HOgydEiHUfIzlGAo327+ccqtHckmAC7LQSN5Haa6 Z5UNQtL1Gjft+KREzQ2JwCxF2GwQlUH5Y4I7zHRf8ozdy8s4O6qf882d9flEzLcOo2q9L 44VG4+KJbMqoxQb9JuTViPzIQmKcd6+MqL404pwHznpoHi+arhopcxpBGgemQmzgfezdb KOF8m1Y9XrTvP/UTrxNSavfaGslsf/X4hLhfcq/CXkzRMoxVwPzneLMaNp7Dz69SEgA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796238236; h=Received:DKIM-Signature:Date:To:From:In-Reply-To:References:Subject: Message-Id; bh=MIfp+fcXmX5MKFlEokBidRd1sRgqSw3o86ORKoUrDuI=; b=hLZx5YAYuHhkvXmQD6Ng3R6kISTX14Q5ax+wfdPBN4FXCJcOMFX7QeOKJVHqlRaQSb2O a9dbWtYMa35Q8CMpC4HrFGX2cf13R6ZnP+hU5VnKvcWVZ9ZkdJyPdLFf6z4qkpdzz+fWM 13wKdb2b2/LXM91Sb1N06FhpOeeRab2w5dNmApKAVpPSjMbg6/Rqs7eHAmKa78yab3jY4 JQpquoq3GPkjVh9plqEJhfCE5WzVOYxuYxiVGmi506VskWWc8HpTZuMMA9Jzrop3TE51s 9KBy1Ls0b96hPa4q20GuDuQ/k92k8Y0OEeBUBdYlLHD0LB+JrF+/jCB2V8wWiPhNjIw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Gj2a5u+I; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDA1B606A322 for ; Wed, 2 Dec 2026 19:03:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux-foundation.org header.i=@linux-foundation.org header.a=rsa-sha256 header.s=korg header.b=Gj2a5u+I Received: by smtp.kernel.org (Postfix) with ESMTPSA id 758B81F00893; Wed, 2 Dec 2026 19:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=korg; t=1796238235; bh=MIfp+fcXmX5MKFlEokBidRd1sRgqSw3o86ORKoUrDuI=; h=Date:To:From:In-Reply-To:References:Subject; b=Gj2a5u+IK6TM/U0cedBmcHRF/3CdkJlfghtT5HBY0PcqajGIvJR3DH8U2gnNwEFAF iiIk6CgkRuY8GNT3VSSD5MG43FUIaIKySpN+UgmLCPWgLMlTERbRz7vAFadnMZeVkL w4bmheA7dJzk9l96bBJPyjgDdaJgdgdOQlyW5R3A= Date: Wed, 02 Dec 2026 11:03:55 -0800 To: mm-commits@vger.kernel.org,yonghong.song@linux.dev,tj@kernel.org, ndesaulniers@google.com,nathan@kernel.org,morbo@google.com, martin.lau@linux.dev,justinstitt@google.com,eddyz87@gmail.com, dennis@kernel.org,daniel@iogearbox.net,cl@gentwo.org,chris@chrisdown.name, ast@kernel.org,andrii@kernel.org,acme@kernel.org,vineet.gupta@linux.dev, akpm@linux-foundation.org From: Andrew Morton In-Reply-To: <20261117220824.609017-1-vineet.gupta@linux.dev> References: <20261117220824.609017-1-vineet.gupta@linux.dev> Subject: + percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations.patch added to mm-new branch Message-Id: <20261202190355.758B81F00893@smtp.kernel.org> X-Mailing-List: mm-commits@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list The patch titled Subject: percpu: do not put btf_type_tag on per-cpu variable declarations has been added to the -mm mm-new branch. Its filename is percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations.patch This patch will later appear in the mm-new branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Note, mm-new is a provisional staging ground for work-in-progress patches, and acceptance into mm-new is a notification for others take notice and to finish up reviews. Please do not hesitate to respond to review feedback and post updated versions to replace or incrementally fixup patches in mm-new. The mm-new branch of mm.git is not included in linux-next If a few days of testing in mm-new is successful, the patch will me moved into mm.git's mm-unstable branch, which is included in linux-next Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via various branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there most days ------------------------------------------------------ From: Vineet Gupta Subject: percpu: do not put btf_type_tag on per-cpu variable declarations Date: Tue, 17 Nov 2026 14:08:24 -0800 __percpu carries BTF_TYPE_TAG(percpu), which records that a pointer points to per-cpu memory. __PCPU_ATTRS() applies __percpu to the per-cpu variable itself, so DECLARE_PER_CPU() and DEFINE_PER_CPU() put the tag in declaration specifier position on the variable's own type. arch/x86/include/asm/processor.h has DECLARE_PER_CPU_READ_MOSTLY(struct cpuinfo_x86, cpu_info); which an x86 defconfig preprocesses to extern __seg_gs __attribute__((btf_type_tag("percpu"))) __attribute__((section(".data..percpu" "..read_mostly"))) __typeof__(struct cpuinfo_x86) cpu_info; 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. The compiler is right to object to a type tag on the aggregate, and the issue is fundamental: every variant of an aggregate shares one DIE, so there is nowhere to put it. clang drops it silently and GCC warns. The tag is meant to record that a pointer points to per-cpu memory, and cpu_info is not a pointer. And this gets worse: for a pointer-typed per-cpu variable GCC attaches the tag to the pointee, so static DEFINE_PER_CPU(struct bpf_hrtimer *, hrtimer_running); comes out as PTR -> TYPE_TAG 'percpu' -> struct bpf_hrtimer. The truth is the other way round: hrtimer_running lives in per-cpu memory and points at ordinary memory, while that record says it is an ordinary pointer to per-cpu memory. clang emits no tag there at all. Add __percpu_var, which skips the btf tag (__percpu under sparse) and use it in __PCPU_ATTRS(). The cpu_info declaration above becomes extern __seg_gs __attribute__((section(".data..percpu" "..read_mostly"))) __typeof__(struct cpuinfo_x86) cpu_info; The pointer spelling, T __percpu *p, is unchanged and keeps its tag. Before this patch the tag also qualified the variable's type, so &var had type "T __percpu *", and a pointer does have a DIE of its own: pahole emitted PTR -> TYPE_TAG 'percpu' -> T for each one. this_cpu_ptr(&var) is that shape, and that is where the records came from. Those are the records an x86 defconfig built with clang loses: 280 BTF types, 140 TYPE_TAG and the 140 pointers carrying them, with .BTF shrinking by 3360 bytes. They are the derived pointers -- clang never recorded the declarations themselves. None of them were reachable: a record points at a type only if something is declared with it, and nothing is declared with these. The 803 places that do declare a "T __percpu *" keep theirs -- the 110 tagged pointers that something references are the same before and after. .text is byte-identical. Link: https://patch.msgid.link/20261117220824.609017-1-vineet.gupta@linux.dev Signed-off-by: Vineet Gupta Signed-off-by: Andrew Morton Reviewed-by: Chris Down Tested-by: Chris Down Cc: Dennis Zhou Cc: Tejun Heo Cc: Christoph Lameter Cc: Alexei Starovoitov Cc: Andrii Nakryiko Cc: Daniel Borkmann Cc: Arnaldo Carvalho de Melo Cc: Yonghong Song Cc: Eduard Zingerman Cc: Cc: Nathan Chancellor Cc: Nick Desaulniers Cc: Bill Wendling Cc: Justin Stitt include/linux/compiler_types.h | 8 ++++++++ include/linux/percpu-defs.h | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) --- a/include/linux/compiler_types.h~percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations +++ a/include/linux/compiler_types.h @@ -50,6 +50,7 @@ # define __user __attribute__((noderef, address_space(__user))) # define __iomem __attribute__((noderef, address_space(__iomem))) # define __percpu __attribute__((noderef, address_space(__percpu))) +# define __percpu_var __percpu # define __rcu __attribute__((noderef, address_space(__rcu))) static inline void __chk_user_ptr(const volatile void __user *ptr) { } static inline void __chk_io_ptr(const volatile void __iomem *ptr) { } @@ -68,7 +69,14 @@ static inline void __chk_io_ptr(const vo # define __user BTF_TYPE_TAG(user) # endif # define __iomem +/* + * btf_type_tag records "points to per-cpu memory", so it belongs on the + * pointer spelling only. Declaring the per-cpu variable itself puts the tag + * in declaration specifier position, where clang drops it and GCC attaches it + * to the wrong type, so __percpu_var leaves it out. + */ # define __percpu __percpu_qual BTF_TYPE_TAG(percpu) +# define __percpu_var __percpu_qual # define __rcu BTF_TYPE_TAG(rcu) # define __chk_user_ptr(x) (void)0 --- a/include/linux/percpu-defs.h~percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations +++ a/include/linux/percpu-defs.h @@ -45,7 +45,7 @@ * that section. */ #define __PCPU_ATTRS(sec) \ - __percpu __attribute__((section(PER_CPU_BASE_SECTION sec))) \ + __percpu_var __attribute__((section(PER_CPU_BASE_SECTION sec))) \ PER_CPU_ATTRIBUTES #define __PCPU_DUMMY_ATTRS \ _ Patches currently in -mm which might be from vineet.gupta@linux.dev are percpu-do-not-put-btf_type_tag-on-per-cpu-variable-declarations.patch