The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Drew Fustini <fustini@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: linux-kernel@vger.kernel.org, linux-riscv@lists.infradead.org
Subject: Re: [PATCH v3 3/8] riscv: Add support for srmcfg CSR from Ssqosid extension
Date: Mon, 29 Jun 2026 15:46:32 -0700	[thread overview]
Message-ID: <akL1yNTmMvfB3uzy@x1> (raw)
In-Reply-To: <20260628212820.D0DD51F000E9@smtp.kernel.org>

On Sun, Jun 28, 2026 at 09:28:20PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Medium] Failing cpuhp_setup_state skips PM notifier registration, silently breaking QoS IDs across system suspend/resume.
> --
> 
> commit e3ff463a672a85eb328bf3048323a464af88e408
> Author: Drew Fustini <fustini@kernel.org>
> 
> riscv: Add support for srmcfg CSR from Ssqosid extension
> 
> This commit adds support for the srmcfg CSR defined in the Ssqosid ISA
> extension. It introduces a per-task thread field and a per-CPU cache to track
> Resource Control ID (RCID) and Monitoring Counter ID (MCID) fields, updating
> the CSR during context switches.
> 
> Link: https://github.com/riscv/riscv-ssqosid/releases/tag/v1.0
> 
> [ ... ]
> 
> > diff --git a/arch/riscv/kernel/qos.c b/arch/riscv/kernel/qos.c
> > new file mode 100644
> > index 0000000000000..c8900d91996f2
> > --- /dev/null
> > +++ b/arch/riscv/kernel/qos.c
> 
> [ ... ]
> 
> > +static int __init riscv_srmcfg_init(void)
> > +{
> > +	int err;
> > +
> > +	if (!riscv_has_extension_unlikely(RISCV_ISA_EXT_SSQOSID))
> > +		return 0;
> > +
> > +	/*
> > +	 * 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);
> > +	if (err < 0) {
> > +		pr_warn("srmcfg cpuhp registration failed (%d), cpus brought online after boot will not invalidate the CSR_SRMCFG cache\n",
> > +			err);
> > +		return err;
> 
> [Severity: Medium]
> If cpuhp_setup_state() fails and returns early here, the
> cpu_pm_register_notifier() registration is skipped, but the hardware
> capability RISCV_ISA_EXT_SSQOSID remains active.
> 
> Because returning an error from an arch_initcall does not halt the boot
> process, the QoS feature will remain active in the kernel.
> 
> If the PM notifier is not registered to invalidate the software cache upon
> exit from low-power states, will subsequent context switches find a cache
> match, mistakenly bypass the csr_write(), and execute tasks with the wrong
> hardware QoS ID?

Yes, it is possible. The early return in riscv_srmcfg_init() does skip
cpu_pm_register_notifier(), and that notifier is what invalidates the
per-cpu srmcfg cache across suspend/resume, so __switch_to_srmcfg()
could find a stale match and skip the csr write.

The risk is low, though. CPUHP_AP_ONLINE_DYN is a valid state, the
registration name is not null, and riscv_srmcfg_reset_cache() cannot
fail, so the only way cpuhp_setup_state() can fail is when no dynamic
hotplug states remain.

However, the fix is simple. The PM notifier is independent of the cpuhp
state, so I'll change riscv_srmcfg_init() to register it even if the
cpuhp setup failed.

Thanks,
Drew

  reply	other threads:[~2026-06-29 22:46 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-28 21:18 [PATCH v3 0/8] riscv: Add Ssqosid and initial CBQRI resctrl support Drew Fustini
2026-06-28 21:18 ` [PATCH v3 1/8] dt-bindings: riscv: Add Ssqosid extension description Drew Fustini
2026-06-28 21:18 ` [PATCH v3 2/8] riscv: Detect the Ssqosid extension Drew Fustini
2026-06-28 21:18 ` [PATCH v3 3/8] riscv: Add support for srmcfg CSR from " Drew Fustini
2026-06-28 21:28   ` sashiko-bot
2026-06-29 22:46     ` Drew Fustini [this message]
2026-06-28 21:18 ` [PATCH v3 4/8] riscv_cbqri: Add capacity controller probe and allocation device ops Drew Fustini
2026-06-28 21:28   ` sashiko-bot
2026-06-28 21:18 ` [PATCH v3 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask Drew Fustini
2026-06-28 21:34   ` sashiko-bot
2026-06-28 21:18 ` [PATCH v3 6/8] riscv: Enable resctrl filesystem for Ssqosid Drew Fustini
2026-06-28 21:30   ` sashiko-bot
2026-06-28 21:18 ` [PATCH v3 7/8] dt-bindings: riscv: Add binding for CBQRI controllers Drew Fustini
2026-06-29 15:32   ` Conor Dooley
2026-06-28 21:18 ` [PATCH v3 8/8] riscv_cbqri: Add CBQRI capacity allocation platform driver Drew Fustini
2026-06-28 21:27   ` sashiko-bot

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=akL1yNTmMvfB3uzy@x1 \
    --to=fustini@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox