Re: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension

Paul Walmsley <[email protected]>
Newsgroups org.kernel.vger.linux-doc,dev.linux.lists.linux-rt-devel,org.infradead.lists.linux-riscv,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.