From: sashiko-bot@kernel.org
To: "Yunhui Cui" <cuiyunhui@bytedance.com>,
pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
alex@ghiti.fr, dennis@kernel.org, tj@kernel.org, cl@gentwo.org,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, memxor@gmail.com,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
bjorn@kernel.org, pulehui@huawei.com, puranjay@kernel.org,
thuth@redhat.com, ajones@ventanamicro.com,
ben.dooks@codethink.co.uk, rkrcmar@ventanamicro.com,
samuel.holland@sifive.com, zong.li@sifive.com,
conor.dooley@microchip.com, tglx@kernel.org, debug@rivosinc.com,
seanwascoding@gmail.com, andybnac@gmail.com,
menglong8.dong@gmail.com, cyrilbur@tenstorrent.com,
wangruikang@iscas.ac.cn, atishp@rivosinc.com,
apatel@ventanamicro.com, linux-mm@kvack.org, bpf@vger.kernel.org,
arnd@arndb.de, nathan@kernel.org,
nick.desaulniers+lkml@gmail.com, morbo@google.com,
justinstitt@google.com, qingfang.deng@siflower.com.cn,
dave@stgolabs.net, emil@etsalap atis.com ,
ihor.solodrai@linux.dev, broonie@kernel.org
Subject: Re: [PATCH v9 1/3] riscv: implement this_cpu operations
Date: Sun, 08 Nov 2026 11:43:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-203699@kernel.org> (raw)
In-Reply-To: <20261108110406.97495-2-cuiyunhui@bytedance.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] riscv: percpu: typeof(pcp) retains __percpu and const qualifiers
in locals
--
commit 9753271dee3a084b7bff8ad7ad29d76cb64e49f4
Author: Yunhui Cui <cuiyunhui@bytedance.com>
riscv: implement this_cpu operations
This commit implements RISC-V-specific this_cpu operations using preemption
disablement and relaxed AMOs (or 32-bit LR/SC for 8-bit and 16-bit accesses
when Zabha is unavailable).
Link: https://lore.kernel.org/r/20260826010748.zphu3wh2hlm4t4o2@offworld
> diff --git a/arch/riscv/include/asm/percpu.h b/arch/riscv/include/asm/percpu.h
> new file mode 100644
> index 0000000000000..280b122b9fe69
> --- /dev/null
> +++ b/arch/riscv/include/asm/percpu.h
[ ... ]
> +#define _pcp_protect_return(op, pcp, args...) \
> +({ \
> + typeof(pcp) __retval; \
> + preempt_disable_notrace(); \
> + __retval = (typeof(pcp))op(raw_cpu_ptr(&(pcp)), ##args); \
> + preempt_enable_notrace(); \
> + __retval; \
> +})
> +
> +#define _pcp_protect_cmpxchg_return(op, pcp, old, new) \
> +({ \
> + typeof(pcp) __retval; \
> + typeof(pcp) *__pcp_ptr; \
> + \
> + preempt_disable_notrace(); \
> + __pcp_ptr = raw_cpu_ptr(&(pcp)); \
> + instrument_atomic_read_write(__pcp_ptr, sizeof(*__pcp_ptr)); \
> + __retval = (typeof(pcp))op(__pcp_ptr, (unsigned long)(old), \
> + (unsigned long)(new)); \
> + preempt_enable_notrace(); \
> + __retval; \
> +})
[ ... ]
> +#define this_cpu_cmpxchg128(pcp, o, n) \
> +({ \
> + u128 old__ = (o), new__ = (n), ret__; \
> + typeof(pcp) *ptr__; \
> + \
> + preempt_disable_notrace(); \
> + ptr__ = raw_cpu_ptr(&(pcp)); \
> + if (system_has_cmpxchg128()) \
> + ret__ = cmpxchg128_local(ptr__, old__, new__); \
> + else \
> + ret__ = __percpu_generic_cmpxchg128(ptr__, old__, new__); \
> + preempt_enable_notrace(); \
> + ret__; \
> +})
[Severity: Low]
Should _pcp_protect_return(), _pcp_protect_cmpxchg_return(), and
this_cpu_cmpxchg128() use TYPEOF_UNQUAL(pcp) instead of typeof(pcp) for
their local variables and pointers?
typeof(pcp) retains the __percpu address-space and const qualifiers from
pcp. Because raw_cpu_ptr() strips __percpu via PERCPU_PTR() (since commit
6a39fe05ecaa ("percpu: use TYPEOF_UNQUAL() in *_cpu_ptr() accessors")),
declaring __pcp_ptr and ptr__ with typeof(pcp) * leaves them in the
__percpu address space and triggers sparse address-space mismatch warnings
on assignment from raw_cpu_ptr() and when passing them to helpers taking
regular pointers. Retaining const on __retval also causes a build error if
this_cpu_read() is used on a const per-CPU variable.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261108110406.97495-1-cuiyunhui@bytedance.com?part=1
next prev parent reply other threads:[~2026-11-08 11:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-08 11:04 [PATCH v9 0/3] riscv: optimize percpu access Yunhui Cui
2026-11-08 11:04 ` [PATCH v9 1/3] riscv: implement this_cpu operations Yunhui Cui
2026-11-08 11:43 ` sashiko-bot [this message]
2026-11-08 11:58 ` bot+bpf-ci
2026-11-08 21:32 ` David Laight
2026-11-09 3:47 ` [External] " yunhui cui
2026-11-09 4:37 ` Jisheng Zhang
2026-11-09 5:49 ` yunhui cui
2026-11-09 11:56 ` Jisheng Zhang
2026-11-08 11:04 ` [PATCH v9 2/3] riscv: store percpu offset into thread_info Yunhui Cui
2026-11-08 11:04 ` [PATCH v9 3/3] riscv: select HAVE_CMPXCHG_LOCAL Yunhui Cui
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=sashiko-outbox-203699@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ajones@ventanamicro.com \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=andybnac@gmail.com \
--cc=aou@eecs.berkeley.edu \
--cc=apatel@ventanamicro.com \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=atishp@rivosinc.com \
--cc=ben.dooks@codethink.co.uk \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=cl@gentwo.org \
--cc=conor.dooley@microchip.com \
--cc=cuiyunhui@bytedance.com \
--cc=cyrilbur@tenstorrent.com \
--cc=daniel@iogearbox.net \
--cc=dave@stgolabs.net \
--cc=debug@rivosinc.com \
--cc=dennis@kernel.org \
--cc=eddyz87@gmail.com \
--cc=emil@etsalap \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-mm@kvack.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=menglong8.dong@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=nick.desaulniers+lkml@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=qingfang.deng@siflower.com.cn \
--cc=rkrcmar@ventanamicro.com \
--cc=samuel.holland@sifive.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=seanwascoding@gmail.com \
--cc=song@kernel.org \
--cc=tglx@kernel.org \
--cc=thuth@redhat.com \
--cc=tj@kernel.org \
--cc=wangruikang@iscas.ac.cn \
--cc=yonghong.song@linux.dev \
--cc=zong.li@sifive.com \
/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