From: Drew Fustini <fustini@kernel.org>
To: Paul Walmsley <pjw@kernel.org>
Cc: "Adrien Ricciardi" <aricciardi@baylibre.com>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Atish Kumar Patra" <atishp@rivosinc.com>,
"Atish Patra" <atish.patra@linux.dev>,
"Babu Moger" <babu.moger@amd.com>,
"Ben Horgan" <ben.horgan@arm.com>,
"Borislav Petkov" <bp@alien8.de>,
"Chen Pei" <cp0613@linux.alibaba.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Conor Dooley" <conor+dt@kernel.org>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Dave Martin" <Dave.Martin@arm.com>,
"Fenghua Yu" <fenghuay@nvidia.com>,
"Gong Shuai" <gong.shuai@sanechips.com.cn>,
"Gong Shuai" <gsh517@gmail.com>,
guo.wenjia23@zte.com.cn, "James Morse" <james.morse@arm.com>,
"Kornel Dulęba" <mindal@semihalf.com>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
liu.qingtao2@zte.com.cn,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Peter Newman" <peternewman@google.com>,
"Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Reinette Chatre" <reinette.chatre@intel.com>,
"Rob Herring" <robh@kernel.org>,
"Samuel Holland" <samuel.holland@sifive.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Tony Luck" <tony.luck@intel.com>,
"Vasudevan Srinivasan" <vasu@rivosinc.com>,
"Ved Shanbhogue" <ved@rivosinc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"yunhui cui" <cuiyunhui@bytedance.com>,
"Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
x86@kernel.org, devicetree@vger.kernel.org,
linux-rt-devel@lists.linux.dev, linux-doc@vger.kernel.org
Subject: Re: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension
Date: Wed, 5 Aug 2026 13:50:44 -0700 [thread overview]
Message-ID: <anOiJHmU24Lpbizi@x1> (raw)
In-Reply-To: <3b6dd35e-dabb-3cb0-547f-0c8a0b035e1a@kernel.org>
On Wed, Aug 05, 2026 at 12:54:42PM -0600, Paul Walmsley wrote:
> Hi,
>
> On Wed, 29 Jul 2026, Drew Fustini wrote:
>
> > Add support for the srmcfg CSR defined in the Ssqosid ISA extension.
> > The CSR contains two fields:
> >
> > - Resource Control ID (RCID) for resource allocation
> > - Monitoring Counter ID (MCID) for tracking resource usage
> >
> > Requests from a hart to shared resources are tagged with these IDs,
> > allowing resource usage to be associated with the running task.
> >
> > Add a srmcfg field to thread_struct with the same format as the CSR.
> > The context-switch path writes the field to the CSR, and
> > resctrl_arch_set_closid_rmid() updates it when a task is assigned to a
> > resctrl control or monitoring group.
> >
> > A per-cpu cpu_srmcfg_default holds the default srmcfg for each CPU, set
> > by resctrl_arch_set_cpu_default_closid_rmid() on CPU group assignment.
> > On context switch, RCID and MCID inherit from the CPU default
> > independently: a task whose thread RCID field is zero takes the CPU
> > default's RCID, and likewise for MCID.
>
> Thanks, queued for v7.3, but with one change (below):
>
> > diff --git a/arch/riscv/include/asm/qos.h b/arch/riscv/include/asm/qos.h
> > new file mode 100644
> > index 000000000000..cf19e8438bb9
> > --- /dev/null
> > +++ b/arch/riscv/include/asm/qos.h
> > @@ -0,0 +1,74 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _ASM_RISCV_QOS_H
> > +#define _ASM_RISCV_QOS_H
> > +
> > +#include <linux/percpu-defs.h>
> > +
> > +#ifdef CONFIG_RISCV_ISA_SSQOSID
> > +
> > +#include <linux/bitfield.h>
> > +#include <linux/cpufeature.h>
> > +#include <linux/sched.h>
> > +
> > +#include <asm/csr.h>
> > +#include <asm/hwcap.h>
> > +
> > +/* cached value of srmcfg csr for each cpu */
> > +DECLARE_PER_CPU(u32, cpu_srmcfg);
> > +
> > +/* default srmcfg value for each cpu, set via resctrl cpu assignment */
> > +DECLARE_PER_CPU(u32, cpu_srmcfg_default);
> > +
> > +static inline void __switch_to_srmcfg(struct task_struct *next)
> > +{
> > + u32 thread_srmcfg, default_srmcfg;
> > +
> > + thread_srmcfg = READ_ONCE(next->thread.srmcfg);
>
> What is the intent of the READ_ONCE() here?
>
> I've dropped it from what's been queued for now. If it's really
> needed, please let us know why.
>
>
> thanks,
>
> - Paul
Thanks for queuing this patch. It is okay to leave out the READ_ONCE()
since only Patches 1-3 are being applied.
The READ_ONCE() is meant to pair with the WRITE_ONCE() in
resctrl_arch_set_closid_rmid(), which comes in patch 5. RCID and MCID
share the srmcfg csr, and resctrl can update thread.srmcfg from another
hart while this task is switched in.
Without READ_ONCE(), the compiler may reload the field between the zero
test and the two FIELD_GET() calls, so thread_srmcfg could end up with
RCID from the old value and MCID from the new one. arm64 MPAM uses
READ_ONCE() here for the same reason for mpam_get_regval() in
arch/arm64/include/asm/mpam.h
Thanks,
Drew
WARNING: multiple messages have this Message-ID (diff)
From: Drew Fustini <fustini@kernel.org>
To: Paul Walmsley <pjw@kernel.org>
Cc: "Adrien Ricciardi" <aricciardi@baylibre.com>,
"Alexandre Ghiti" <alex@ghiti.fr>,
"Atish Kumar Patra" <atishp@rivosinc.com>,
"Atish Patra" <atish.patra@linux.dev>,
"Babu Moger" <babu.moger@amd.com>,
"Ben Horgan" <ben.horgan@arm.com>,
"Borislav Petkov" <bp@alien8.de>,
"Chen Pei" <cp0613@linux.alibaba.com>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Conor Dooley" <conor+dt@kernel.org>,
"Dave Hansen" <dave.hansen@linux.intel.com>,
"Dave Martin" <Dave.Martin@arm.com>,
"Fenghua Yu" <fenghuay@nvidia.com>,
"Gong Shuai" <gong.shuai@sanechips.com.cn>,
"Gong Shuai" <gsh517@gmail.com>,
guo.wenjia23@zte.com.cn, "James Morse" <james.morse@arm.com>,
"Kornel Dulęba" <mindal@semihalf.com>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
liu.qingtao2@zte.com.cn,
"Liu Zhiwei" <zhiwei_liu@linux.alibaba.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Peter Newman" <peternewman@google.com>,
"Radim Krčmář" <rkrcmar@ventanamicro.com>,
"Reinette Chatre" <reinette.chatre@intel.com>,
"Rob Herring" <robh@kernel.org>,
"Samuel Holland" <samuel.holland@sifive.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Tony Luck" <tony.luck@intel.com>,
"Vasudevan Srinivasan" <vasu@rivosinc.com>,
"Ved Shanbhogue" <ved@rivosinc.com>,
"Weiwei Li" <liwei1518@gmail.com>,
"yunhui cui" <cuiyunhui@bytedance.com>,
"Zhanpeng Zhang" <zhangzhanpeng.jasper@bytedance.com>,
linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org,
x86@kernel.org, devicetree@vger.kernel.org,
linux-rt-devel@lists.linux.dev, linux-doc@vger.kernel.org
Subject: Re: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension
Date: Wed, 5 Aug 2026 13:50:44 -0700 [thread overview]
Message-ID: <anOiJHmU24Lpbizi@x1> (raw)
In-Reply-To: <3b6dd35e-dabb-3cb0-547f-0c8a0b035e1a@kernel.org>
On Wed, Aug 05, 2026 at 12:54:42PM -0600, Paul Walmsley wrote:
> Hi,
>
> On Wed, 29 Jul 2026, Drew Fustini wrote:
>
> > Add support for the srmcfg CSR defined in the Ssqosid ISA extension.
> > The CSR contains two fields:
> >
> > - Resource Control ID (RCID) for resource allocation
> > - Monitoring Counter ID (MCID) for tracking resource usage
> >
> > Requests from a hart to shared resources are tagged with these IDs,
> > allowing resource usage to be associated with the running task.
> >
> > Add a srmcfg field to thread_struct with the same format as the CSR.
> > The context-switch path writes the field to the CSR, and
> > resctrl_arch_set_closid_rmid() updates it when a task is assigned to a
> > resctrl control or monitoring group.
> >
> > A per-cpu cpu_srmcfg_default holds the default srmcfg for each CPU, set
> > by resctrl_arch_set_cpu_default_closid_rmid() on CPU group assignment.
> > On context switch, RCID and MCID inherit from the CPU default
> > independently: a task whose thread RCID field is zero takes the CPU
> > default's RCID, and likewise for MCID.
>
> Thanks, queued for v7.3, but with one change (below):
>
> > diff --git a/arch/riscv/include/asm/qos.h b/arch/riscv/include/asm/qos.h
> > new file mode 100644
> > index 000000000000..cf19e8438bb9
> > --- /dev/null
> > +++ b/arch/riscv/include/asm/qos.h
> > @@ -0,0 +1,74 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _ASM_RISCV_QOS_H
> > +#define _ASM_RISCV_QOS_H
> > +
> > +#include <linux/percpu-defs.h>
> > +
> > +#ifdef CONFIG_RISCV_ISA_SSQOSID
> > +
> > +#include <linux/bitfield.h>
> > +#include <linux/cpufeature.h>
> > +#include <linux/sched.h>
> > +
> > +#include <asm/csr.h>
> > +#include <asm/hwcap.h>
> > +
> > +/* cached value of srmcfg csr for each cpu */
> > +DECLARE_PER_CPU(u32, cpu_srmcfg);
> > +
> > +/* default srmcfg value for each cpu, set via resctrl cpu assignment */
> > +DECLARE_PER_CPU(u32, cpu_srmcfg_default);
> > +
> > +static inline void __switch_to_srmcfg(struct task_struct *next)
> > +{
> > + u32 thread_srmcfg, default_srmcfg;
> > +
> > + thread_srmcfg = READ_ONCE(next->thread.srmcfg);
>
> What is the intent of the READ_ONCE() here?
>
> I've dropped it from what's been queued for now. If it's really
> needed, please let us know why.
>
>
> thanks,
>
> - Paul
Thanks for queuing this patch. It is okay to leave out the READ_ONCE()
since only Patches 1-3 are being applied.
The READ_ONCE() is meant to pair with the WRITE_ONCE() in
resctrl_arch_set_closid_rmid(), which comes in patch 5. RCID and MCID
share the srmcfg csr, and resctrl can update thread.srmcfg from another
hart while this task is switched in.
Without READ_ONCE(), the compiler may reload the field between the zero
test and the two FIELD_GET() calls, so thread_srmcfg could end up with
RCID from the old value and MCID from the new one. arm64 MPAM uses
READ_ONCE() here for the same reason for mpam_get_regval() in
arch/arm64/include/asm/mpam.h
Thanks,
Drew
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next prev parent reply other threads:[~2026-08-05 20:50 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-30 1:11 [PATCH v6 0/8] riscv: Add Ssqosid and initial CBQRI resctrl support Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 1/8] dt-bindings: riscv: Add Ssqosid extension description Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-08-05 2:46 ` Paul Walmsley
2026-08-05 2:46 ` Paul Walmsley
2026-07-30 1:11 ` [PATCH v6 2/8] riscv: Detect the Ssqosid extension Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-08-05 2:47 ` Paul Walmsley
2026-08-05 2:47 ` Paul Walmsley
2026-08-05 3:40 ` Drew Fustini
2026-08-05 3:40 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 3/8] riscv: Add support for srmcfg CSR from " Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:22 ` sashiko-bot
2026-07-30 2:04 ` Drew Fustini
2026-07-30 2:04 ` Drew Fustini
2026-08-05 18:54 ` Paul Walmsley
2026-08-05 18:54 ` Paul Walmsley
2026-08-05 20:50 ` Drew Fustini [this message]
2026-08-05 20:50 ` Drew Fustini
2026-08-06 1:21 ` Paul Walmsley
2026-08-06 1:21 ` Paul Walmsley
2026-07-30 1:11 ` [PATCH v6 4/8] riscv_cbqri: Add capacity controller probe and allocation device ops Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:27 ` sashiko-bot
2026-07-30 2:09 ` Drew Fustini
2026-07-30 2:09 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 6/8] riscv: Enable resctrl filesystem for Ssqosid Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 7/8] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:11 ` [PATCH v6 8/8] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-07-30 1:11 ` Drew Fustini
2026-07-30 1:21 ` sashiko-bot
2026-07-30 2:11 ` Drew Fustini
2026-07-30 2:11 ` Drew Fustini
2026-08-05 3:00 ` [PATCH v6 0/8] riscv: Add Ssqosid and initial CBQRI resctrl support patchwork-bot+linux-riscv
2026-08-05 3:00 ` patchwork-bot+linux-riscv
2026-08-05 19:00 ` patchwork-bot+linux-riscv
2026-08-05 19:00 ` patchwork-bot+linux-riscv
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=anOiJHmU24Lpbizi@x1 \
--to=fustini@kernel.org \
--cc=Dave.Martin@arm.com \
--cc=alex@ghiti.fr \
--cc=aricciardi@baylibre.com \
--cc=atish.patra@linux.dev \
--cc=atishp@rivosinc.com \
--cc=babu.moger@amd.com \
--cc=ben.horgan@arm.com \
--cc=bigeasy@linutronix.de \
--cc=bp@alien8.de \
--cc=conor+dt@kernel.org \
--cc=conor.dooley@microchip.com \
--cc=cp0613@linux.alibaba.com \
--cc=cuiyunhui@bytedance.com \
--cc=dave.hansen@linux.intel.com \
--cc=devicetree@vger.kernel.org \
--cc=fenghuay@nvidia.com \
--cc=gong.shuai@sanechips.com.cn \
--cc=gsh517@gmail.com \
--cc=guo.wenjia23@zte.com.cn \
--cc=james.morse@arm.com \
--cc=krzk+dt@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=linux-rt-devel@lists.linux.dev \
--cc=liu.qingtao2@zte.com.cn \
--cc=liwei1518@gmail.com \
--cc=mindal@semihalf.com \
--cc=palmer@dabbelt.com \
--cc=peternewman@google.com \
--cc=pjw@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=rkrcmar@ventanamicro.com \
--cc=robh@kernel.org \
--cc=samuel.holland@sifive.com \
--cc=tony.luck@intel.com \
--cc=vasu@rivosinc.com \
--cc=ved@rivosinc.com \
--cc=x86@kernel.org \
--cc=zhangzhanpeng.jasper@bytedance.com \
--cc=zhiwei_liu@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.