Re: [PATCH RFC v5 11/18] riscv_cbqri: resctrl: Add cache allocation via capacity block mask

From: Drew Fustini

Date: Mon May 25 2026 - 03:40:38 EST


On Mon, May 25, 2026 at 12:50:55AM +0000, sashiko-bot@xxxxxxxxxx wrote:
> > @@ -595,6 +595,7 @@ config RISCV_ISA_SSQOSID
> > bool "Ssqosid extension support for supervisor mode Quality of Service ID"
> > depends on 64BIT
> > default n
> > + select ARCH_HAS_CPU_RESCTRL
>
> [Severity: High]
> Could this lead to build failures if the CBQRI driver is not enabled?
>
> The Kconfig symbol RISCV_ISA_SSQOSID unconditionally selects
> ARCH_HAS_CPU_RESCTRL, which signals to the core kernel that the architecture
> provides the resctrl_arch_* interface. This permits CONFIG_RESCTRL_FS to be
> enabled.
>
> However, since the implementation resides in drivers/resctrl/cbqri_resctrl.c
> which is only compiled when CONFIG_RISCV_CBQRI_DRIVER is set, enabling
> RISCV_ISA_SSQOSID and RESCTRL_FS without RISCV_CBQRI_DRIVER might cause
> linker errors due to undefined references to the resctrl_arch_* functions.
> Would it be safer to add a dependency on the driver?

The combination of SSQOSID=y RESCTRL_FS=y RISCV_CBQRI_DRIVER=n should
not be reachable.

> > +static int cbqri_resctrl_online_cpu(unsigned int cpu)
> > +{
> > + struct cbqri_controller *ctrl;
> > + int err = 0;
> > +
> > + mutex_lock(&cbqri_domain_list_lock);
> > +
> > + list_for_each_entry(ctrl, &cbqri_controllers, list) {
> > + if (ctrl->type != CBQRI_CONTROLLER_TYPE_CAPACITY)
> > + continue;
> > + if (!cpumask_test_cpu(cpu, &ctrl->cache.cpu_mask))
> > + continue;
> > + if (!ctrl->alloc_capable)
> > + continue;
> > +
> > + err = cbqri_attach_cpu_to_cap_ctrl(ctrl, cpu);
> > + if (err)
> > + break;
> > + }
>
> [Severity: High]
> Does this loop leave the system in an inconsistent state if it fails partway
> through?

Yes, I will update v6 to track the last successfully attached controller
and walk the list backwards from there on error.

> Should we reset the per-CPU default closid and rmid when a CPU comes online?
>
> Does this missing notification leave the generic resctrl subsystem out of sync?

Yes to both. I will make v6 follow the same approach of x86
resctrl_arch_online_cpu().

Drew