All of lore.kernel.org
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	x86@kernel.org
Subject: Re: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension
Date: Wed, 29 Jul 2026 19:04:58 -0700	[thread overview]
Message-ID: <amqxSpkxWw6/zXcq@x1> (raw)
In-Reply-To: <20260730012227.58F5C1F000E9@smtp.kernel.org>

On Thu, Jul 30, 2026 at 01:22:26AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] The `srmcfg` CSR is not initialized during early boot or CPU hotplug bringup, leaving CPUs running with undefined QoS tags.
> - [Medium] The architecture-specific resctrl setters `resctrl_arch_set_closid_rmid()` and `resctrl_arch_set_cpu_default_closid_rmid()` are missing.
> --
> 
> --- Patch [3]: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension ---
> commit a02eee11a5e49e74d1e00459d9acc1ec4a1982fa
> Author: Drew Fustini <fustini@kernel.org>
> 
> riscv: Add support for srmcfg CSR from Ssqosid extension
> 
> Add support for the srmcfg CSR defined in the Ssqosid ISA extension.
> The CSR contains two fields: Resource Control ID (RCID) and Monitoring
> Counter ID (MCID) for tracking resource usage.
> 
> Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0
> 
> > 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.
> 
> [Severity: Medium]
> Neither resctrl_arch_set_closid_rmid() nor
> resctrl_arch_set_cpu_default_closid_rmid() appear to be implemented in this
> patch. 
> 
> Since they are missing, are thread_struct.srmcfg and cpu_srmcfg_default ever
> actually modified from their initial zero values?

Both are added in patch 5 along with the rest of the resctrl glue. I
already explained that this is not a problem but sashiko doesn't read
replies.

> > diff --git a/arch/riscv/kernel/qos.c b/arch/riscv/kernel/qos.c
> > index 0000000000000..99925c0e93dd8
> > --- /dev/null
> > +++ b/arch/riscv/kernel/qos.c
> > @@ -0,0 +1,101 @@
> 
> [ ... ]
> 
> > +	/*
> > +	 * cpuhp_setup_state() invokes the startup callback locally on every
> > +	 * already-online CPU, so no separate seed loop is needed here.
> > +	 */
> > +	err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "riscv/srmcfg:online",
> > +				riscv_srmcfg_reset_cache, riscv_srmcfg_reset_cache);
> 
> [Severity: High]
> Does this software cache correctly handle CPU hotplug and early boot?
> 
> When a CPU is offlined, it continues context-switching as it goes down, which
> overwrites the U32_MAX cache sentinel with a valid tag (such as 0 for the idle
> thread).
> 
> When the CPU is brought back online, its hardware srmcfg CSR is reset to an
> implementation-defined value. If the software cache cpu_srmcfg is still 0, the
> first context switch to a task with a 0 tag in __switch_to_srmcfg() will see
> thread_srmcfg == cpu_srmcfg and skip the CSR write:
> 
> arch/riscv/include/asm/qos.h:__switch_to_srmcfg() {
>     ...
>     if (thread_srmcfg != __this_cpu_read(cpu_srmcfg)) {
>         __this_cpu_write(cpu_srmcfg, thread_srmcfg);
>         csr_write(CSR_SRMCFG, thread_srmcfg);
>     }
>     ...
> }
> 
> This leaves the hardware CSR undefined until this CPUHP_AP_ONLINE_DYN startup
> callback runs. Is CPUHP_AP_ONLINE_DYN too late to prevent the CPU from running
> with undefined QoS tags?

This is not a problem. Only the idle task and per-cpu kthreads run in
that window, and they run with the hart's reset srmcfg value.

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: sashiko-reviews@lists.linux.dev
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
	x86@kernel.org
Subject: Re: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension
Date: Wed, 29 Jul 2026 19:04:58 -0700	[thread overview]
Message-ID: <amqxSpkxWw6/zXcq@x1> (raw)
In-Reply-To: <20260730012227.58F5C1F000E9@smtp.kernel.org>

On Thu, Jul 30, 2026 at 01:22:26AM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [High] The `srmcfg` CSR is not initialized during early boot or CPU hotplug bringup, leaving CPUs running with undefined QoS tags.
> - [Medium] The architecture-specific resctrl setters `resctrl_arch_set_closid_rmid()` and `resctrl_arch_set_cpu_default_closid_rmid()` are missing.
> --
> 
> --- Patch [3]: [PATCH v6 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension ---
> commit a02eee11a5e49e74d1e00459d9acc1ec4a1982fa
> Author: Drew Fustini <fustini@kernel.org>
> 
> riscv: Add support for srmcfg CSR from Ssqosid extension
> 
> Add support for the srmcfg CSR defined in the Ssqosid ISA extension.
> The CSR contains two fields: Resource Control ID (RCID) and Monitoring
> Counter ID (MCID) for tracking resource usage.
> 
> Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0
> 
> > 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.
> 
> [Severity: Medium]
> Neither resctrl_arch_set_closid_rmid() nor
> resctrl_arch_set_cpu_default_closid_rmid() appear to be implemented in this
> patch. 
> 
> Since they are missing, are thread_struct.srmcfg and cpu_srmcfg_default ever
> actually modified from their initial zero values?

Both are added in patch 5 along with the rest of the resctrl glue. I
already explained that this is not a problem but sashiko doesn't read
replies.

> > diff --git a/arch/riscv/kernel/qos.c b/arch/riscv/kernel/qos.c
> > index 0000000000000..99925c0e93dd8
> > --- /dev/null
> > +++ b/arch/riscv/kernel/qos.c
> > @@ -0,0 +1,101 @@
> 
> [ ... ]
> 
> > +	/*
> > +	 * cpuhp_setup_state() invokes the startup callback locally on every
> > +	 * already-online CPU, so no separate seed loop is needed here.
> > +	 */
> > +	err = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "riscv/srmcfg:online",
> > +				riscv_srmcfg_reset_cache, riscv_srmcfg_reset_cache);
> 
> [Severity: High]
> Does this software cache correctly handle CPU hotplug and early boot?
> 
> When a CPU is offlined, it continues context-switching as it goes down, which
> overwrites the U32_MAX cache sentinel with a valid tag (such as 0 for the idle
> thread).
> 
> When the CPU is brought back online, its hardware srmcfg CSR is reset to an
> implementation-defined value. If the software cache cpu_srmcfg is still 0, the
> first context switch to a task with a 0 tag in __switch_to_srmcfg() will see
> thread_srmcfg == cpu_srmcfg and skip the CSR write:
> 
> arch/riscv/include/asm/qos.h:__switch_to_srmcfg() {
>     ...
>     if (thread_srmcfg != __this_cpu_read(cpu_srmcfg)) {
>         __this_cpu_write(cpu_srmcfg, thread_srmcfg);
>         csr_write(CSR_SRMCFG, thread_srmcfg);
>     }
>     ...
> }
> 
> This leaves the hardware CSR undefined until this CPUHP_AP_ONLINE_DYN startup
> callback runs. Is CPUHP_AP_ONLINE_DYN too late to prevent the CPU from running
> with undefined QoS tags?

This is not a problem. Only the idle task and per-cpu kthreads run in
that window, and they run with the hart's reset srmcfg value.

Drew

  reply	other threads:[~2026-07-30  2:05 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 [this message]
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
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=amqxSpkxWw6/zXcq@x1 \
    --to=fustini@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=x86@kernel.org \
    /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.