All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse
@ 2026-01-18 14:45 Thomas Gleixner
  2026-01-18 15:00 ` [tip: timers/vdso] " tip-bot2 for Thomas Gleixner
  2026-01-18 17:25 ` [PATCH] " Uros Bizjak
  0 siblings, 2 replies; 3+ messages in thread
From: Thomas Gleixner @ 2026-01-18 14:45 UTC (permalink / raw)
  To: LKML; +Cc: x86

Now that sparse builds enforce the usage of typeof_unqual() the casts in
__raw_cpu_read/write() cause sparse to emit tons of false postive
warnings:

 warning: cast removes address space '__percpu' of expression

Address this by annotating the casts with __force.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Closes: https://lore.kernel.org/oe-kbuild-all/202601181733.YZOf9XU3-lkp@intel.com/
---
 arch/x86/include/asm/percpu.h |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -137,12 +137,12 @@
 
 #define __raw_cpu_read(size, qual, pcp)					\
 ({									\
-	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp));		\
+	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp));	\
 })
 
-#define __raw_cpu_write(size, qual, pcp, val)				\
-do {									\
-	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);	\
+#define __raw_cpu_write(size, qual, pcp, val)					\
+do {										\
+	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)) = (val);	\
 } while (0)
 
 #define __raw_cpu_read_const(pcp)	__raw_cpu_read(, , pcp)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip: timers/vdso] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse
  2026-01-18 14:45 [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse Thomas Gleixner
@ 2026-01-18 15:00 ` tip-bot2 for Thomas Gleixner
  2026-01-18 17:25 ` [PATCH] " Uros Bizjak
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot2 for Thomas Gleixner @ 2026-01-18 15:00 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: kernel test robot, Thomas Gleixner, x86, linux-kernel

The following commit has been merged into the timers/vdso branch of tip:

Commit-ID:     bbef8e2c29c32f048fac8e07f884f827d028f1da
Gitweb:        https://git.kernel.org/tip/bbef8e2c29c32f048fac8e07f884f827d028f1da
Author:        Thomas Gleixner <tglx@kernel.org>
AuthorDate:    Sun, 18 Jan 2026 15:45:40 +01:00
Committer:     Thomas Gleixner <tglx@kernel.org>
CommitterDate: Sun, 18 Jan 2026 15:54:17 +01:00

x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse

Now that sparse builds enforce the usage of typeof_unqual() the casts in
__raw_cpu_read/write() cause sparse to emit tons of false postive
warnings:

 warning: cast removes address space '__percpu' of expression

Address this by annotating the casts with __force.

Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Link: https://patch.msgid.link/87v7gz0yjv.ffs@tglx
Closes: https://lore.kernel.org/oe-kbuild-all/202601181733.YZOf9XU3-lkp@intel.com/
---
 arch/x86/include/asm/percpu.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/percpu.h b/arch/x86/include/asm/percpu.h
index 725d0ef..c55058f 100644
--- a/arch/x86/include/asm/percpu.h
+++ b/arch/x86/include/asm/percpu.h
@@ -137,12 +137,12 @@
 
 #define __raw_cpu_read(size, qual, pcp)					\
 ({									\
-	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp));		\
+	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp));	\
 })
 
-#define __raw_cpu_write(size, qual, pcp, val)				\
-do {									\
-	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);	\
+#define __raw_cpu_write(size, qual, pcp, val)					\
+do {										\
+	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)) = (val);	\
 } while (0)
 
 #define __raw_cpu_read_const(pcp)	__raw_cpu_read(, , pcp)

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse
  2026-01-18 14:45 [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse Thomas Gleixner
  2026-01-18 15:00 ` [tip: timers/vdso] " tip-bot2 for Thomas Gleixner
@ 2026-01-18 17:25 ` Uros Bizjak
  1 sibling, 0 replies; 3+ messages in thread
From: Uros Bizjak @ 2026-01-18 17:25 UTC (permalink / raw)
  To: Thomas Gleixner, LKML; +Cc: x86



On 1/18/26 15:45, Thomas Gleixner wrote:
> Now that sparse builds enforce the usage of typeof_unqual() the casts in
> __raw_cpu_read/write() cause sparse to emit tons of false postive
> warnings:
> 
>   warning: cast removes address space '__percpu' of expression
> 
> Address this by annotating the casts with __force.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Thomas Gleixner <tglx@kernel.org>
> Closes: https://lore.kernel.org/oe-kbuild-all/202601181733.YZOf9XU3-lkp@intel.com/
> ---
>   arch/x86/include/asm/percpu.h |    8 ++++----
>   1 file changed, 4 insertions(+), 4 deletions(-)
> 
> --- a/arch/x86/include/asm/percpu.h
> +++ b/arch/x86/include/asm/percpu.h
> @@ -137,12 +137,12 @@
>   
>   #define __raw_cpu_read(size, qual, pcp)					\
>   ({									\
> -	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp));		\
> +	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp));	\
>   })
>   
> -#define __raw_cpu_write(size, qual, pcp, val)				\
> -do {									\
> -	*(qual __my_cpu_type(pcp) *)__my_cpu_ptr(&(pcp)) = (val);	\
> +#define __raw_cpu_write(size, qual, pcp, val)					\
> +do {										\
> +	*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)) = (val);	\
>   } while (0)
>   
>   #define __raw_cpu_read_const(pcp)	__raw_cpu_read(, , pcp)

Perhaps these defines can be simplified a bit as:

#define __raw_cpu_read(size, qual, pcp) \
	(*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)))

#define __raw_cpu_write(size, qual, pcp, val) \
	(*(qual __my_cpu_type(pcp) * __force)__my_cpu_ptr(&(pcp)) = (val))

Uros.



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-01-18 17:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-18 14:45 [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse Thomas Gleixner
2026-01-18 15:00 ` [tip: timers/vdso] " tip-bot2 for Thomas Gleixner
2026-01-18 17:25 ` [PATCH] " Uros Bizjak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.