Re: [PATCH v2 5/8] riscv_cbqri: resctrl: Add cache allocation via capacity block mask
From: Drew Fustini
Date: Fri Jun 26 2026 - 16:44:45 EST
On Thu, Jun 25, 2026 at 01:53:55AM +0000, sashiko-bot@xxxxxxxxxx wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [High] Traversing the global `cbqri_controllers` list without holding `cbqri_controllers_lock` during CPU hotplug risks list corruption.
> --
>
> commit e1c49060a1fc98c61e36689ccda2041d360bb762
> Author: Drew Fustini <fustini@xxxxxxxxxx>
>
> riscv_cbqri: resctrl: Add cache allocation via capacity block mask
>
> This commit wires up the CBQRI capacity controllers into resctrl as
> RDT_RESOURCE_L2 and RDT_RESOURCE_L3 schemata. It treats mismatched
> capabilities at the same cache level as a fatal error and lazily creates
> domains in the cpuhp online callback.
>
> > diff --git a/drivers/resctrl/cbqri_resctrl.c b/drivers/resctrl/cbqri_resctrl.c
> > new file mode 100644
> > index 0000000000000..2f31baff032b6
> > --- /dev/null
> > +++ b/drivers/resctrl/cbqri_resctrl.c
> [ ... ]
> > +static int cbqri_attach_cpu_to_all_ctrls(unsigned int cpu)
> > +{
> > + struct cbqri_controller *ctrl;
> > + int err = 0;
> > +
> > + lockdep_assert_held(&cbqri_domain_list_lock);
> > +
> > + list_for_each_entry(ctrl, &cbqri_controllers, list) {
>
> [Severity: High]
> Is it safe to iterate the global cbqri_controllers list without holding
> cbqri_controllers_lock?
>
> If a capacity controller is dynamically added at runtime (e.g., via a device
> tree overlay instantiating the platform device), its probe function can acquire
> cbqri_controllers_lock and mutate the cbqri_controllers list.
>
> Concurrently, if a CPU is hotplugged, the cpuhp online callback calls
> cbqri_resctrl_online_cpu() which invokes this function. Traversing the list
> here while holding only cbqri_domain_list_lock could lead to list corruption,
> resulting in an infinite loop or NULL pointer dereference.
I will update cbqri_attach_cpu_to_all_ctrls() to take the
cbqri_controllers_lock before iterating through the cbqri_controllers
list.
Drew