All of lore.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: "Radim Krčmář" <rkrcmar@ventanamicro.com>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Conor Dooley" <conor@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Kornel Dulęba" <mindal@semihalf.com>,
	"Adrien Ricciardi" <aricciardi@baylibre.com>,
	"James Morse" <james.morse@arm.com>,
	"Atish Kumar Patra" <atishp@rivosinc.com>,
	"Atish Patra" <atish.patra@linux.dev>,
	"Vasudevan Srinivasan" <vasu@rivosinc.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	guo.wenjia23@zte.com.cn, liu.qingtao2@zte.com.cn,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	linux-riscv <linux-riscv-bounces@lists.infradead.org>
Subject: Re: [PATCH v4 3/3] RISC-V: Add support for srmcfg CSR from Ssqosid ext
Date: Fri, 7 Nov 2025 09:44:17 -0800	[thread overview]
Message-ID: <aQ4v8QhQjRYrxNK3@x1> (raw)
In-Reply-To: <DDH2Q0N2HLKF.2QSW4DB5FTJI6@ventanamicro.com>

On Mon, Oct 13, 2025 at 11:06:50AM +0200, Radim Krčmář wrote:
> 2025-10-11T11:35:46-07:00, Drew Fustini <fustini@kernel.org>:
> > On Thu, Oct 09, 2025 at 08:47:27AM +0200, Radim Krčmář wrote:
> >> 2025-10-07T23:21:12-07:00, Drew Fustini <fustini@kernel.org>:
> >> > diff --git a/arch/riscv/include/asm/qos.h b/arch/riscv/include/asm/qos.h
> >> > +static inline void __switch_to_srmcfg(struct task_struct *next)
> >> > +{
> >> > +	u32 *cpu_srmcfg_ptr = this_cpu_ptr(&cpu_srmcfg);
> >> > +	u32 thread_srmcfg;
> >> > +
> >> > +	thread_srmcfg = READ_ONCE(next->thread.srmcfg);
> >> > +
> >> > +	if (thread_srmcfg != *cpu_srmcfg_ptr) {
> >> 
> >> Wouldn't prev->thread.srmcfg have the value of CSR_SRMCFG when executing
> >> switch_to?
> >
> > Thanks for reviewing. Yes, you are right that prev->thread.srmcfg should
> > have same value as CSR_SRMCFG. Are you suggesting that the cpu_srmcfg is
> > not necessary as prev->thread.srmcfg should have same value?
> 
> Yes, it would be more consistent with other context switched state.
> I just wasn't sure if srmcfg doesn't have special race conditions.

I did some testing and the per-cpu cache of CSR_SRMCFG is needed. This
is because thread.srmcfg is changed asynchronously from when CSR_SRMCFG
is updated in __switch_to_srmcfg.

The srmcfg value for a thread is updated when a user writes the pid to a
control group's tasks file in the resctrl virtual filesystem:

void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
{
       u32 srmcfg;

       WARN_ON_ONCE((closid & SRMCFG_RCID_MASK) != closid);
       WARN_ON_ONCE((rmid & SRMCFG_MCID_MASK) != rmid);

       srmcfg = rmid << SRMCFG_MCID_SHIFT;
       srmcfg |= closid;
       WRITE_ONCE(tsk->thread.srmcfg, srmcfg);
}

I'm getting a full patch series ready that has both the Ssqosid and the
CBQRI resctrl patches, and I will post that soon. I'm also preparing
a freshly rebased Qemu series that adds the CBQRI controllers.

Thanks,
Drew

_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Drew Fustini <fustini@kernel.org>
To: "Radim Krčmář" <rkrcmar@ventanamicro.com>
Cc: "Paul Walmsley" <paul.walmsley@sifive.com>,
	"Palmer Dabbelt" <palmer@dabbelt.com>,
	"Albert Ou" <aou@eecs.berkeley.edu>,
	"Alexandre Ghiti" <alex@ghiti.fr>,
	"Conor Dooley" <conor@kernel.org>,
	"Rob Herring" <robh@kernel.org>,
	"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
	"Conor Dooley" <conor+dt@kernel.org>,
	"Kornel Dulęba" <mindal@semihalf.com>,
	"Adrien Ricciardi" <aricciardi@baylibre.com>,
	"James Morse" <james.morse@arm.com>,
	"Atish Kumar Patra" <atishp@rivosinc.com>,
	"Atish Patra" <atish.patra@linux.dev>,
	"Vasudevan Srinivasan" <vasu@rivosinc.com>,
	"Conor Dooley" <conor.dooley@microchip.com>,
	guo.wenjia23@zte.com.cn, liu.qingtao2@zte.com.cn,
	linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	devicetree@vger.kernel.org,
	linux-riscv <linux-riscv-bounces@lists.infradead.org>
Subject: Re: [PATCH v4 3/3] RISC-V: Add support for srmcfg CSR from Ssqosid ext
Date: Fri, 7 Nov 2025 09:44:17 -0800	[thread overview]
Message-ID: <aQ4v8QhQjRYrxNK3@x1> (raw)
In-Reply-To: <DDH2Q0N2HLKF.2QSW4DB5FTJI6@ventanamicro.com>

On Mon, Oct 13, 2025 at 11:06:50AM +0200, Radim Krčmář wrote:
> 2025-10-11T11:35:46-07:00, Drew Fustini <fustini@kernel.org>:
> > On Thu, Oct 09, 2025 at 08:47:27AM +0200, Radim Krčmář wrote:
> >> 2025-10-07T23:21:12-07:00, Drew Fustini <fustini@kernel.org>:
> >> > diff --git a/arch/riscv/include/asm/qos.h b/arch/riscv/include/asm/qos.h
> >> > +static inline void __switch_to_srmcfg(struct task_struct *next)
> >> > +{
> >> > +	u32 *cpu_srmcfg_ptr = this_cpu_ptr(&cpu_srmcfg);
> >> > +	u32 thread_srmcfg;
> >> > +
> >> > +	thread_srmcfg = READ_ONCE(next->thread.srmcfg);
> >> > +
> >> > +	if (thread_srmcfg != *cpu_srmcfg_ptr) {
> >> 
> >> Wouldn't prev->thread.srmcfg have the value of CSR_SRMCFG when executing
> >> switch_to?
> >
> > Thanks for reviewing. Yes, you are right that prev->thread.srmcfg should
> > have same value as CSR_SRMCFG. Are you suggesting that the cpu_srmcfg is
> > not necessary as prev->thread.srmcfg should have same value?
> 
> Yes, it would be more consistent with other context switched state.
> I just wasn't sure if srmcfg doesn't have special race conditions.

I did some testing and the per-cpu cache of CSR_SRMCFG is needed. This
is because thread.srmcfg is changed asynchronously from when CSR_SRMCFG
is updated in __switch_to_srmcfg.

The srmcfg value for a thread is updated when a user writes the pid to a
control group's tasks file in the resctrl virtual filesystem:

void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid)
{
       u32 srmcfg;

       WARN_ON_ONCE((closid & SRMCFG_RCID_MASK) != closid);
       WARN_ON_ONCE((rmid & SRMCFG_MCID_MASK) != rmid);

       srmcfg = rmid << SRMCFG_MCID_SHIFT;
       srmcfg |= closid;
       WRITE_ONCE(tsk->thread.srmcfg, srmcfg);
}

I'm getting a full patch series ready that has both the Ssqosid and the
CBQRI resctrl patches, and I will post that soon. I'm also preparing
a freshly rebased Qemu series that adds the CBQRI controllers.

Thanks,
Drew

  reply	other threads:[~2025-11-07 17:44 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08  6:21 [PATCH v4 0/3] RISC-V: Detect Ssqosid extension and handle srmcfg CSR Drew Fustini
2025-10-08  6:21 ` Drew Fustini
2025-10-08  6:21 ` [PATCH v4 1/3] dt-bindings: riscv: Add Ssqosid extension description Drew Fustini
2025-10-08  6:21   ` Drew Fustini
2025-10-08  6:21 ` [PATCH v4 2/3] RISC-V: Detect the Ssqosid extension Drew Fustini
2025-10-08  6:21   ` Drew Fustini
2025-10-08  6:21 ` [PATCH v4 3/3] RISC-V: Add support for srmcfg CSR from Ssqosid ext Drew Fustini
2025-10-08  6:21   ` Drew Fustini
2025-10-09  6:47   ` Radim Krčmář
2025-10-09  6:47     ` Radim Krčmář
2025-10-11 18:35     ` Drew Fustini
2025-10-11 18:35       ` Drew Fustini
2025-10-13  9:06       ` Radim Krčmář
2025-10-13  9:06         ` Radim Krčmář
2025-11-07 17:44         ` Drew Fustini [this message]
2025-11-07 17:44           ` Drew Fustini
2025-10-10 12:23 ` [External] [PATCH v4 0/3] RISC-V: Detect Ssqosid extension and handle srmcfg CSR yunhui cui
2025-10-10 12:23   ` yunhui cui
2025-10-10 21:56   ` Drew Fustini
2025-10-10 21:56     ` Drew Fustini
2025-12-24  8:40     ` yunhui cui
2025-12-24  8:40       ` yunhui cui
2025-12-24 22:48       ` Drew Fustini
2025-12-24 22:48         ` Drew Fustini

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=aQ4v8QhQjRYrxNK3@x1 \
    --to=fustini@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=aricciardi@baylibre.com \
    --cc=atish.patra@linux.dev \
    --cc=atishp@rivosinc.com \
    --cc=conor+dt@kernel.org \
    --cc=conor.dooley@microchip.com \
    --cc=conor@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=guo.wenjia23@zte.com.cn \
    --cc=james.morse@arm.com \
    --cc=krzk+dt@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv-bounces@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liu.qingtao2@zte.com.cn \
    --cc=mindal@semihalf.com \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.com \
    --cc=rkrcmar@ventanamicro.com \
    --cc=robh@kernel.org \
    --cc=vasu@rivosinc.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.