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=1796376486; b=aWuVdW6xhDuAjv+E2wQp4mn9T9z+69jHRG/Oc0vaikH9Sbrds7byWdy0s7p4yRfyfTSw /tCFh+bjcXckKRwh5EsJBKH59f3B5HtNOTwPsbKXmqXOtQVqDPjbBNgBQvlKUneR1hRyy 67AGLQOwNjo+WiGnqSlQIy8tx4ISnrZcceJagfM+I8nn/PZSeHKGPYz6xhhyZYHD02Cmi OGSK/M3T1fF8grz1rFdDflyZEEtf9eXNG8z0SywYVmJF2BSz2lpFdBDFVUdB6WBEskM+o CkknrGl0os1Ap+9MqwqObzQ5YeUfWfAO9M9tf8NIqZDv2Qb1vm3kw0Qj9RfS9QlPCpg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796376486; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=KcdIWG81GO6mbkn/glDt7BK8VVtviDFkWB+V95fjqWM=; b=hwpSrrYMHo9ude/I5MzAXJnMCwV/JTip6cxsMEv+Eh7sVj8w1F5krNYqh9/q50/UiQYK gvorJF2/4tln06MEXF7xJLm3RBRD2/xnFSt6Cri3bODw62fOmUQkv+2jJTfjE92vA34k8 no5cHsJaYDG/hn6UueHjg2ekzJupaPWnOSkeQ6c5DYBuUO8c/ZJpdC9fAAZ+dwyR2d6OP fQUib+6MiwyEnpctUjEJIZYw1vR1VmGGNtu/gBGCmEKfsCnTpRIzTorbL5E4bfuu77MoJ ddmzZm/r73Ss7Re0n2cpyfAk5lFV17tobYHRbT7165/jw+ITRjN7aUWYqJqpU8TK2fA== 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=UqCrnKp1; 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 60B52606A322 for ; Fri, 4 Dec 2026 09:28:06 +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=UqCrnKp1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id DE1841F00897; Fri, 4 Dec 2026 09:28:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796376486; bh=KcdIWG81GO6mbkn/glDt7BK8VVtviDFkWB+V95fjqWM=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=UqCrnKp1rSBtqEVxvMI1HOK0W+eo+/CDCL75NASQwQUmjXaP3eKgGfvXHa+uZkjuk IwhrJ10oVRzi2F1WH6xIRjB9pwvu9V1g3l4v2X2uNchagIGRBRbm+DNLp6dtCUkXAx c4T2V4vMa4xXTbMOlvfou/UoAbS3OYkeUIjRlr2XuoVrp7Agy15NPDDSaY86A6dQlb hWEBrEVTqn3tJzTTtvHZbnGF3n54QCxjf8judEXKTTFWYWsvdXxeTWq06IT88LmoD9 hxT1sDango+80MVe6Pm4j2zTLtLYnyoNFyb3vXpg46tnRANN20dLFfpmcyCf6vpZjA IXby7hvWQWqCQ== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v12 05/10] riscv: implement preemptible this_cpu void RMW operations 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: <20261204085859.42277-6-cuiyunhui@bytedance.com> References: <20261204085859.42277-1-cuiyunhui@bytedance.com> <20261204085859.42277-6-cuiyunhui@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:28:03 +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: pcpu_gprs false-shares task_struct cache line in this_cpu RMWs -- commit fcc4ea085ec85e941f656b028f16ce10e5de0a9f Author: Yunhui Cui riscv: implement preemptible this_cpu void RMW operations This commit wires the RISC-V this_cpu_{add,and,or}_{1,2,4,8} operations to the preemptible per-CPU AMO helpers instead of falling back to the generic implementations. Link: https://lore.kernel.org/r/20260826010748.zphu3wh2hlm4t4o2@offworld > diff --git a/arch/riscv/include/asm/percpu.h b/arch/riscv/include/asm/per= cpu.h > index d46a32c78c5dc..6d0a11b49563f 100644 > --- a/arch/riscv/include/asm/percpu.h > +++ b/arch/riscv/include/asm/percpu.h [ ... ] > @@ -243,6 +260,27 @@ PERCPU_RW_OPS("lw", "sw", 32) > _pcp_wrap(__percpu_write_64, pcp, (__force unsigned long)(val)) > #endif > =20 > +#define this_cpu_add_1(pcp, val) _pcp_wrap(__percpu_add_amo_case_8, pcp,= val) > +#define this_cpu_add_2(pcp, val) _pcp_wrap(__percpu_add_amo_case_16, pcp= , val) > +#define this_cpu_add_4(pcp, val) _pcp_wrap(__percpu_add_amo_case_32, pcp= , val) > +#ifdef CONFIG_64BIT > +#define this_cpu_add_8(pcp, val) _pcp_wrap(__percpu_add_amo_case_64, pcp= , val) > +#endif > + > +#define this_cpu_and_1(pcp, val) _pcp_wrap(__percpu_and_amo_case_8, pcp,= val) > +#define this_cpu_and_2(pcp, val) _pcp_wrap(__percpu_and_amo_case_16, pcp= , val) > +#define this_cpu_and_4(pcp, val) _pcp_wrap(__percpu_and_amo_case_32, pcp= , val) > +#ifdef CONFIG_64BIT > +#define this_cpu_and_8(pcp, val) _pcp_wrap(__percpu_and_amo_case_64, pcp= , val) > +#endif > + > +#define this_cpu_or_1(pcp, val) _pcp_wrap(__percpu_or_amo_case_8, pcp, = val) > +#define this_cpu_or_2(pcp, val) _pcp_wrap(__percpu_or_amo_case_16, pcp,= val) > +#define this_cpu_or_4(pcp, val) _pcp_wrap(__percpu_or_amo_case_32, pcp,= val) > +#ifdef CONFIG_64BIT > +#define this_cpu_or_8(pcp, val) _pcp_wrap(__percpu_or_amo_case_64, pcp,= val) > +#endif [Severity: Medium] Does placing pcpu_gprs at the end of struct thread_info cause split-line accesses and false sharing with task_struct on every this_cpu RMW? On RV64 SMP (L1_CACHE_BYTES =3D=3D 64 with CONFIG_THREAD_INFO_IN_TASK), pcpu_offset is at offset 40 (cache line 0), while pcpu_gprs follows a0, a1, and a2 at offset 72 (cache line 1). Remotely accessed task_struct fields (__state, usage, on_cpu, wake_entry) share the rest of that line. Because these helpers read pcpu_offset and write pcpu_gprs twice on every call, hot paths like percpu_ref_get() now touch two cache lines of current and continuously dirty cache line 1, causing cross-CPU cacheline bouncing whenever another CPU wakes or takes a reference on the running task. Moving pcpu_gprs right after pcpu_offset (ahead of a0, a1, and a2) would keep both fields in cache line 0 and avoid false sharing with task_struct. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261204085859.4227= 7-1-cuiyunhui@bytedance.com?part=3D5