From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9E808606A322 for ; Thu, 3 Dec 2026 14:39:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=N5tdZUyi Received: by kanga.kvack.org (Postfix) id 7648C6B05B9; Thu, 3 Dec 2026 09:39:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 714A36B05CF; Thu, 3 Dec 2026 09:39:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5B6FA6B05D1; Thu, 3 Dec 2026 09:39:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 30C406B05B9 for ; Thu, 3 Dec 2026 09:39:53 -0500 (EST) Received: from smtpin20.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E947CA0777 for ; Thu, 3 Dec 2026 14:39:50 +0000 (UTC) X-FDA: 85502930940.20.68E4317 Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf19.hostedemail.com (Postfix) with ESMTP id 5E8531A000D for ; Thu, 3 Dec 2026 14:39:49 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=N5tdZUyi; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796308789; b=GPF9UV2nT4BXeWIKMq8kKJDFRM7sbJM+x9NAh2xCBDm6nwoZ7W2ExyMbD9BzimJfHhAX9R jlvkpZW6DXxLDKCR/P4fze6KFAJQq5hOkadYl4H4p2sFyD56rS6q93EyeBB1olgOU70yrI BbZ79c0IZHLK8qBuXPxw0Xz1w7I40ks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796308789; h=from:from:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=08+eGcFNk13JfURg87YlLOO7rC5byqBuO5OCdEV9KvI=; b=k3t+X8vcFephKPE8VSwnkH09ypIieCBDm6fg2oPlxcHZsIipUJUJ7wxpdqNcQoiWhB+2ZA v3FQCiALtslPbG3tCuUy7zGKfIMGS9LfGbe3JFi0W9swO3eEt5fofQgM9J0BIC0lTheErC iR8Lj07Lh+qz+5ZL2kQokeoWNXInklU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=N5tdZUyi; dmarc=pass (policy=quarantine) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sashiko-bot@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=sashiko-bot@kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B84236062C; Thu, 3 Dec 2026 14:39:48 +0000 (UTC) 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@gma il.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-Rspam-User: X-Rspamd-Queue-Id: 5E8531A000D X-Stat-Signature: fb9uyn7up9pdhubmtcjrkydqdgtm94n3 X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Rspamd-Server: rspam02 X-HE-Tag: 1796308789-627895 X-HE-Meta: U2FsdGVkX1/jeJjCCDOfqjL/F4Kz7vhBg5SpR5LmzyFVIN+GIR0y+uHiKXq9PDKd1xnEHfIHxP5SwBoeH4a7ZmzQ3cvx//x/3jBmAUHIuU95bH8TR2V/gsNlgDKmZ2iqOpDj3e+9aV0EGkQ2KtcdiDr/WGrtlaR51/tY3OoLHOrqbDt1zpqS7gfeJWhN+9HCk/0CBDFfGO3v4SBKOl+WaoVa1j2rhdEej0+XFoDKhGOcpiXVAf/VAWlGYNziI3jto1w9kgd7ohlvBEWaYvmvb4II3oUssb7buzxH+i/U8ngdBdSoMGtb+vwhOKAd+vwZrW+W/agr5zC/+tblPgna1Swrn2TvGv+LNX4tTuLfDFui0jNK6uXPXhhF1T9JeHTk/a2dqIDqkGuVHD+iDTE2b2jhkand2Q8gkguMwxfOM2xEV5MSBusVuDKVrbOT3IQmwufWnPS4ga0bZPT2JDzUNWBJKVZtDUFkFsUI8hnqf5SNQtq7rNGEPGFtTP3GNOyEZ4HDla91OpCu72MHyay6EqTrWCgCfQUa9h41pHs6cSclqQ9uyX97rxI40ZO3nB2brTxKlXUwItcFO09LJZ0nlCfGRAFPQvUfiu8Xf9dRtSScUsj9xhPoPIHemSCEvTfhtVMuhlaWzF05rOmUHYSnCQpW6xO9Rpi+oYQ9j0GM6PTiXlCE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e+MamrWlNlzXuFqo8MdUUizSOoWpHpfKQ1GfwRpEyxc6b46yNutQZJOFbRx7awFIC3BZk7PpokIQGlWdoAdglcybZ47zP57yOpLPx4hc6Js3lnctu2ue0iFYSykRsWRqUK1f9FMkzjuUhEt7/N4f0R2GC+195yzU5XPLBHEbeFstgJEQFUV5hyVre6Dcv+M5yQ== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: 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