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=1796376146; b=aDCrzoLYC6QUtaGBgyPoGO76Tuw1x/LW5S5pXSGYlJpXy3kvGtkgPjFPqfz4h7wm4h6F eMiaDzU6K9UmKTPR04mGmWwen1vNLqSYAte9iBsvs1COh5hL9uQTDnI0112yojDeCxeXI 4j7EHHEnbPO20WZQ3t8p4NkxOoVhSCOva99SoxjWiLcUEUOmKgbm53OciwwFA3n5ynLvA hMt89UJoW0b4erTJJa2ID2KCx8fPmuSpW789Nqp6iXwGZzL3lHBYFtYQo3b2dUbbuH2pw Bgo6LLj3CLDnWYnCnPD6xr7vqt1LacBQGwe9kDtYcSHQ1FuvKqisp1759BO0Y0MDQbA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796376146; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=5daM9B6xPZP3sekMjDE09Gb5KMExQydX4NHrbTk5jxM=; b=n6oByf9OVp/kQlOUazyt6Bb2TRKZKmHnqhaPVFkV2ec5ys5fKRFpW6O8v2lgYHGEvWdG 99C5bj9SwFWUoo62XgZJIwL+Z63+KhJIeXeU4dVVCirxxiNmR49HZYgcT5n8wIbi9QsTT X2cEUKOKAIK8QD2xSUJ7+IqcpHTQYLCrOxGRcEwakjWhiD+5dtsST66lf2iEXO7VqMvbU lnjU14vEjhXPeW/aCc1u6385DH/+Wo3T1ZPZImnVEZIHuMmlJCPc4BeDj608AhCqjWKVO XX5XoKKuV9eWFpFaYNYQLRc3OaOhi1mkFCmTVLWeCayQu3BHGiEgkVg6krLgBggFE5g== 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=nyQvFkJc; 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 0B30F606A322 for ; Fri, 4 Dec 2026 09:22:25 +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=nyQvFkJc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 519C71F000C2; Fri, 4 Dec 2026 09:22:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796376145; bh=5daM9B6xPZP3sekMjDE09Gb5KMExQydX4NHrbTk5jxM=; h=From:Subject:Reply-To:To:In-Reply-To:References:Date; b=nyQvFkJc/deDh5sHd9mNPlLb2T2oi/9L3k5IqXrCR5rKkrQ/UAEsG/t3dpp5DZlar IY/FiPsvQ4ytZQXqbDXevRem3agb9m+w5JXpyOl0EzHdbWwOflEoGFwgN4UNQ2mqN6 EB2/vrE5GqNPVznipFJKNbeO0vj8IvSzMEZXRUy0QzfW29Amlmd5PRrg7N0RWbicm4 CK6KirA2mML2dtyew6H9tS2ZDKSheJXFBRegEHGnfYpRx131xBhenarREAmhM3aeHM +XcuVKTGvxHt2ySwu3ifN20A7f2hyte+fFjgJjqQ2YkQZTfu8obYcDnKpX/B7IBPQr 6ieWQO5AcdCFw== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v12 02/10] riscv: add infrastructure for preemptible this_cpu 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-3-cuiyunhui@bytedance.com> References: <20261204085859.42277-1-cuiyunhui@bytedance.com> <20261204085859.42277-3-cuiyunhui@bytedance.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Fri, 04 Dec 2026 09:22:21 +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: thread_info.pcpu_gprs sits in second cacheline causing false sharing -- commit 0d0238bba2276b5a96d3ce6a47b34f916b2e4701 Author: Yunhui Cui riscv: add infrastructure for preemptible this_cpu operations This commit adds per-task tracking of per-CPU address-generation registers = in struct thread_info and struct pt_regs, along with exception entry and exit handling to fix up those registers after CPU migration so RISC-V this_cpu operations can remain preemptible. Link: https://lore.kernel.org/r/20261108213254.67805ef0@pumpkin Link: https://lore.kernel.org/r/avG07pmpcLGkq5i-@xhacker [ ... ] > diff --git a/arch/riscv/include/asm/thread_info.h b/arch/riscv/include/as= m/thread_info.h > index 523e95c1eedb8..4a123d40fbf4d 100644 > --- a/arch/riscv/include/asm/thread_info.h > +++ b/arch/riscv/include/asm/thread_info.h > @@ -79,6 +79,9 @@ struct thread_info { > #ifdef CONFIG_RISCV_USER_CFI > struct cfi_state user_cfi_state; > #endif > +#ifdef CONFIG_SMP > + unsigned short pcpu_gprs; > +#endif > }; [Severity: Medium] Does placing pcpu_gprs at the end of struct thread_info put it in the second cacheline and cause false sharing with struct task_struct? On 64-bit SMP kernels, task_struct embeds thread_info at offset 0 (64-byte aligned) with pcpu_offset at offset 40. Appending pcpu_gprs puts it in the second cacheline (offset 72 on defconfig), sharing it with remote-accessed task_struct fields like __state, usage, on_cpu, on_rq, and wake_entry. pcpu_gprs_entry unconditionally stores zero to pcpu_gprs on every trap in handle_exception() even when already zero, and each this_cpu operation writ= es pcpu_gprs twice while reading pcpu_offset from the first cacheline. This dirties two cachelines and bounces owner->on_cpu in mutex_spin_on_owner(). Placing pcpu_gprs in the first cacheline alongside pcpu_offset (ahead of colder fields like scs_base) and skipping the zero store in pcpu_gprs_entry when the loaded value is already zero would keep hot entry and per-CPU state in one cacheline 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=3D2