From nobody Mon Jun 8 08:30:20 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAAED48B381; Wed, 3 Jun 2026 14:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496711; cv=none; b=Y8Lo4+SZbJ+AUg9B1f8k4qx4iQNHHqyGlddONCP78gdj6kegYl8uESX+GCxgZuWfZwoBiiDsjWiqJFbXWeToVLqhb4seE1G2NpEtiD6qX9ERnlZKOyOfbispXVYFzNCvTz7lBr4iW/vc2iWDOUXFw9YQnwTge+HOzd4gUIZ1ow0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780496711; c=relaxed/simple; bh=U+eH96oWN/wavxWqDnzRWfRSdZq7QNjUewXNfhz9s+k=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=sJM33uFuxK0ZDutAOiSf+JmqawkSbsJB3X6qPaypJ3a6YVtJMl5mdyiNr4RvCBd6rIq1tuu26NCr9wQFMS++0gj5JOzp1mdNgE5snmbIMP86ZazHtYX/WyatGRLpp85xFT/BfMuJa9ET4q+bPLwMT1Y5ImE/T+ibKwH8tXYgGL0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=dVRXXu9y; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=760uUyEU; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="dVRXXu9y"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="760uUyEU" Date: Wed, 03 Jun 2026 14:25:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1780496707; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r5UJ1djSm1SABxWko4Hd0yF4gNiybqJsLKtLYA1FeBI=; b=dVRXXu9yhGTlyvalGFyaZ/qzSIqDb9k9Rl4fUFtqwd/LFAcnGHVq5WIEVQANkgvtnqaQZE Xy7CQqW67vkZBH1bCBAu3u03xcXt4C49MDeJL8KcpbkJMpiQQVy+OSsPJQHvfKAP2dUMR0 +45IAVPonhi/MNaZIlWd/lkcBRMYHrU2zmcve8G4ugsp87ZRNLasxKKqrFlzz/DaTvhprY PYGGhKkw8d1FJlVymE/UX1yauedH0WY1obOh0zzIgvNsIvp9b7D/1x9EDLGtN4ovmNk0W7 3cxzg+BvWL0HX0sSAUP6hYAgpE0VYG3jxRmqyWJ11jikZeCQ2ytB6+AUHBIJcw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1780496707; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r5UJ1djSm1SABxWko4Hd0yF4gNiybqJsLKtLYA1FeBI=; b=760uUyEU3sNVr8vxLrLDPar7flQOhmWeYP5WzZPiVOhkIeyQKYECfdxQZXbWSVlA8guKW9 0pdC88IYfZARy5AQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: locking/core] percpu: Sanitize __percpu_qual include hell Cc: Thomas Gleixner , "Peter Zijlstra (Intel)" , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260602090535.254874125@kernel.org> References: <20260602090535.254874125@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <178049670648.710.4580630575860028037.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the locking/core branch of tip: Commit-ID: c06cd66387da92e6cdac44e16c7b5ef9219c53ac Gitweb: https://git.kernel.org/tip/c06cd66387da92e6cdac44e16c7b5ef92= 19c53ac Author: Thomas Gleixner AuthorDate: Tue, 02 Jun 2026 11:09:21 +02:00 Committer: Peter Zijlstra CommitterDate: Wed, 03 Jun 2026 11:38:48 +02:00 percpu: Sanitize __percpu_qual include hell Slapping __percpu_qual into the next available header is sloppy at best. It's required by __percpu which is defined in compiler_types.h and that is meant to be included without requiring a boatload of other headers so that a struct or function declaration can contain a __percpu qualifier w/o further prerequisites. This implicit dependency on linux/percpu.h makes that impossible and causes a major problem when trying to separate headers. Create asm/percpu_types.h and move it there. Include that from compiler_types.h and the whole recursion problem goes away. Fix up UM so it uses the generic header and includes it in the UM_HOST build, which pulls in compiler_types.h. The USER_CFLAGS fix was suggested by Richard. Signed-off-by: Thomas Gleixner Signed-off-by: Peter Zijlstra (Intel) Link: https://patch.msgid.link/20260602090535.254874125@kernel.org --- arch/um/Makefile | 3 ++- arch/um/include/asm/Kbuild | 1 + arch/x86/include/asm/percpu.h | 5 ----- arch/x86/include/asm/percpu_types.h | 17 +++++++++++++++++ include/asm-generic/Kbuild | 1 + include/asm-generic/percpu_types.h | 19 +++++++++++++++++++ include/linux/compiler_types.h | 3 +++ include/linux/percpu.h | 9 +++++---- 8 files changed, 48 insertions(+), 10 deletions(-) create mode 100644 arch/x86/include/asm/percpu_types.h create mode 100644 include/asm-generic/percpu_types.h diff --git a/arch/um/Makefile b/arch/um/Makefile index 721b652..937639e 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile @@ -71,7 +71,8 @@ USER_CFLAGS =3D $(patsubst $(KERNEL_DEFINES),,$(patsubst = -I%,,$(KBUILD_CFLAGS))) \ -D_FILE_OFFSET_BITS=3D64 -idirafter $(srctree)/include \ -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \ -include $(srctree)/include/linux/compiler-version.h \ - -include $(srctree)/include/linux/kconfig.h + -include $(srctree)/include/linux/kconfig.h \ + -idirafter $(ARCH_DIR)/include/generated =20 #This will adjust *FLAGS accordingly to the platform. include $(srctree)/$(ARCH_DIR)/Makefile-os-Linux diff --git a/arch/um/include/asm/Kbuild b/arch/um/include/asm/Kbuild index 1b9b82b..e91ba12 100644 --- a/arch/um/include/asm/Kbuild +++ b/arch/um/include/asm/Kbuild @@ -16,6 +16,7 @@ generic-y +=3D module.h generic-y +=3D module.lds.h generic-y +=3D parport.h generic-y +=3D percpu.h +generic-y +=3D percpu_types.h generic-y +=3D preempt.h generic-y +=3D runtime-const.h generic-y +=3D softirq_stack.h diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h index 4099814..cef9a4c 100644 --- a/arch/x86/include/asm/percpu.h +++ b/arch/x86/include/asm/percpu.h @@ -40,12 +40,10 @@ #endif =20 #define __percpu_prefix -#define __percpu_seg_override CONCATENATE(__seg_, __percpu_seg) =20 #else /* !CONFIG_CC_HAS_NAMED_AS: */ =20 #define __percpu_prefix __force_percpu_prefix -#define __percpu_seg_override =20 #endif /* CONFIG_CC_HAS_NAMED_AS */ =20 @@ -82,7 +80,6 @@ =20 #define __force_percpu_prefix #define __percpu_prefix -#define __percpu_seg_override =20 #define PER_CPU_VAR(var) (var)__percpu_rel =20 @@ -92,8 +89,6 @@ # define __my_cpu_type(var) typeof(var) # define __my_cpu_ptr(ptr) (ptr) # define __my_cpu_var(var) (var) - -# define __percpu_qual __percpu_seg_override #else # define __my_cpu_type(var) typeof(var) __percpu_seg_override # define __my_cpu_ptr(ptr) (__my_cpu_type(*(ptr))*)(__force uintptr_t)(ptr) diff --git a/arch/x86/include/asm/percpu_types.h b/arch/x86/include/asm/per= cpu_types.h new file mode 100644 index 0000000..0aa3e47 --- /dev/null +++ b/arch/x86/include/asm/percpu_types.h @@ -0,0 +1,17 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_PERCPU_TYPES_H +#define _ASM_X86_PERCPU_TYPES_H + +#if defined(CONFIG_SMP) && defined(CONFIG_CC_HAS_NAMED_AS) +#define __percpu_seg_override CONCATENATE(__seg_, __percpu_seg) +#else /* !CONFIG_CC_HAS_NAMED_AS: */ +#define __percpu_seg_override +#endif + +#if defined(CONFIG_USE_X86_SEG_SUPPORT) && defined(USE_TYPEOF_UNQUAL) +#define __percpu_qual __percpu_seg_override +#endif + +#include + +#endif diff --git a/include/asm-generic/Kbuild b/include/asm-generic/Kbuild index 2c53a1e..15df9dc 100644 --- a/include/asm-generic/Kbuild +++ b/include/asm-generic/Kbuild @@ -44,6 +44,7 @@ mandatory-y +=3D module.lds.h mandatory-y +=3D msi.h mandatory-y +=3D pci.h mandatory-y +=3D percpu.h +mandatory-y +=3D percpu_types.h mandatory-y +=3D pgalloc.h mandatory-y +=3D preempt.h mandatory-y +=3D rqspinlock.h diff --git a/include/asm-generic/percpu_types.h b/include/asm-generic/percp= u_types.h new file mode 100644 index 0000000..a095cea --- /dev/null +++ b/include/asm-generic/percpu_types.h @@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_GENERIC_PERCPU_TYPES_H_ +#define _ASM_GENERIC_PERCPU_TYPES_H_ + +#ifndef __ASSEMBLER__ +/* + * __percpu_qual is the qualifier for the percpu named address space. + * + * Most architectures use generic named address space for percpu variables= but + * some architectures define percpu variables in different named address s= pace. + * E.g. on x86, percpu variable may be declared as being relative to the %= fs or + * %gs segments using __seg_fs or __seg_gs named address space qualifier. + */ +#ifndef __percpu_qual +# define __percpu_qual +#endif + +#endif /* __ASSEMBLER__ */ +#endif /* _ASM_GENERIC_PERCPU_TYPES_H_ */ diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h index e8fd775..7ad37ad 100644 --- a/include/linux/compiler_types.h +++ b/include/linux/compiler_types.h @@ -634,6 +634,9 @@ struct ftrace_likely_data { #else #define __unqual_scalar_typeof(x) __typeof_unqual__(x) #endif + +#include + #endif /* !__ASSEMBLY__ */ =20 /* diff --git a/include/linux/percpu.h b/include/linux/percpu.h index 85bf8dd..2f5a889 100644 --- a/include/linux/percpu.h +++ b/include/linux/percpu.h @@ -3,13 +3,14 @@ #define __LINUX_PERCPU_H =20 #include +#include +#include +#include #include -#include -#include #include -#include -#include +#include #include +#include =20 #include =20