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=1796308788; b=G32y5QUnHh0p0xqALvqkCO3of769Pt/q7DuDa/2C4YQk920p8Zh3JPGFQWl8wn5QKZxN /USdk7xxfnzv0rT5Q9AC82BsjjB421f3fDOrK4L5CfLNR6jDmAXWUvxk996kxaDPUrnEI HRxlj76SSw/8/i2QSwoNGEw+qzw8m45wcSlhwkBtwKyH6DNsw1UEY1J3aNUOsY5+qRaY0 8/qYZiXnHqp+snY4iILQc3fHk2lAX6zGLbguNLLluj3X9hgKFz0ePAYLZze6wq2NAHTMD UZdjuch1pJcRCyE24Nb2LaI8yk5A41EnTQUZlolGX5Cf+uBk/zJTabHGP7wWe6NxEBA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308788; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=08+eGcFNk13JfURg87YlLOO7rC5byqBuO5OCdEV9KvI=; b=qpBwjb6xt7S/uzuGXw0MztA4DHfB+xHHb/51Q48fNhPLHkUNFBoMrStiuWDH9o5lXgj+ +L07DYJJ19d+5Q0vsaGz6seC03HrZoHZ7Z6/2KCsGjhFAvvlPw6R84+kU4/F1Va0/lqvD p52nOVLWHaBug+lwB7y6pDdDwcbbXeyRnKxwF6Wj27m4jkoC4eHZ5qHBVRvUfkKZM+d5j Q886poksdZgp8nK2wgdlYoLqowNjTJC0u1G3pt00s2bg9j21XLwFajUzCLUDC0Gkt8uda +o0JVvEVIyfvOg3kQHIzuyC+vLEPUWk0vzD8PdOoEValitl1wYmhnpRgVUSLUA8EUNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N5tdZUyi; 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 9680A606A322 for ; Thu, 3 Dec 2026 14:39:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N5tdZUyi Received: by smtp.kernel.org (Postfix) with ESMTPSA id 506951F00893; Thu, 3 Dec 2026 14:39:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796308788; bh=08+eGcFNk13JfURg87YlLOO7rC5byqBuO5OCdEV9KvI=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=N5tdZUyiMtMexoEUv+P9AHIh827qWjlVP+DYgpi8FrqssAuIBgktvyrivTwEdxKc/ Rn+mHaFkUou/qCdEg9Bz4R7XM1N4l93gCY+XpHFBM8JEn4VV2y7Ys5Dh0WtWIJo2Wc DmgwAIRHPPEWX5B3Paf0PS32SFj17eGiURxNKAmefjHSERUEoTzZLdy6BIo8nVsT+8 TZvUjg49wQpOjghN1eBTelpj3n2k81sGTRYAjDLAvWidRMcCTpj0G4V8AHdN9JIxcF SoqLhS+iRI8q2rS0mLDzqKIs+liO3tpMtlXPJXxBJ7JomfjD8NJn2eK50VDtx4Uqw0 cf0hXgEOIogog== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v11 09/10] riscv: implement preemptible this_cpu cmpxchg128 Reply-To: sashiko-reviews@lists.linux.dev To: "Yunhui Cui" , pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu, alex@ghiti.fr, dennis@kernel.org, tj@kernel.org, cl@gentwo.org, oleg@redhat.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, bjorn@kernel.org, pulehui@huawei.com, puranjay@kernel.org, broonie@kernel.org, dave@stgolabs.net, david.laight.linux@gmail.com, jszhang@kernel.org, tglx@kernel.org, conor.dooley@microchip.com, thuth@redhat.com, ajones@ventanamicro.com, ben.dooks@codethink.co.uk, rkrcmar@ventanamicro.com, samuel.holland@sifive.com, zong.li@sifive.com, 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, arnd@arndb.de, nathan@kernel.org, nick.desaulniers+lkml@gmail.com, morbo@google.com, justinstitt@google.com, qingfang.deng@siflower.com.cn, linux-mm@kvack.org, bpf@vger.kernel.org In-Reply-To: <20261203135328.32990-10-cuiyunhui@bytedance.com> References: <20261203135328.32990-1-cuiyunhui@bytedance.com> <20261203135328.32990-10-cuiyunhui@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 14:39:45 +0000 X-Mailing-List: bpf@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] riscv: __percpu_generic_cmpxchg128() omits RELOC_HIDE(), duplicates generic -- commit b38800d13faff5874a8e355c1c5f3c4b3deddc6f Author: Yunhui Cui riscv: implement preemptible this_cpu cmpxchg128 This commit adds preemptible 128-bit this_cpu_cmpxchg128() support on RISC-V using amocas.q when Zacas is available, with a local-IRQ-disabled fallback otherwise. > diff --git a/arch/riscv/include/asm/percpu.h b/arch/riscv/include/asm/per= cpu.h > index 5e7365044eae5..a9d8620417e1b 100644 > --- a/arch/riscv/include/asm/percpu.h > +++ b/arch/riscv/include/asm/percpu.h [ ... ] > +static __always_inline u128 > +__percpu_generic_cmpxchg128(void __percpu *pcp, u128 old, u128 new) > +{ > + unsigned long flags; > + u128 *ptr; > + u128 ret; > + > + flags =3D arch_local_irq_save(); > + ptr =3D (u128 *)((__force unsigned long)pcp + > + __my_cpu_offset); > + ret =3D *ptr; > + if (ret =3D=3D old) > + *ptr =3D new; > + arch_local_irq_restore(flags); > + > + return ret; > +} [Severity: Medium] Can computing ptr directly from pcp + __my_cpu_offset without RELOC_HIDE() be miscompiled on CPUs without Zacas? When this_cpu_cmpxchg128() is called on a static per-CPU variable in .data..percpu, GCC assumes arithmetic derived from that symbol stays within the object's bounds and does not wrap, risking miscompilation and per-CPU data corruption. SHIFT_PERCPU_PTR() uses RELOC_HIDE() for this. This helper also duplicates this_cpu_generic_cmpxchg() from include/asm-generic/percpu.h, skips CONFIG_DEBUG_IRQFLAGS checks by using arch_local_irq_save()/restore() instead of raw_local_irq_save()/restore(), and loads __my_cpu_offset unconditionally even when !CONFIG_SMP. Branching on system_has_cmpxchg128() in this_cpu_cmpxchg128() and falling back to this_cpu_generic_cmpxchg() would avoid the pointer provenance issue and drop the duplicate helper. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203135328.3299= 0-1-cuiyunhui@bytedance.com?part=3D9