From: Uros Bizjak <ubizjak@gmail.com>
To: Thomas Gleixner <tglx@kernel.org>, LKML <linux-kernel@vger.kernel.org>
Cc: x86@kernel.org
Subject: Re: [PATCH] x86/percpu: Make CONFIG_USE_X86_SEG_SUPPORT work with sparse
Date: Sun, 18 Jan 2026 18:25:46 +0100 [thread overview]
Message-ID: <31da0378-59be-42fc-a813-be3946d2b504@gmail.com> (raw)
In-Reply-To: <87v7gz0yjv.ffs@tglx>
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.
prev parent reply other threads:[~2026-01-18 17:25 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Uros Bizjak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=31da0378-59be-42fc-a813-be3946d2b504@gmail.com \
--to=ubizjak@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=tglx@kernel.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®