Re: [PATCH RFC 08/19] RISC-V: QoS: add resctrl interface for CBQRI controllers

From: Drew Fustini

Date: Tue Mar 31 2026 - 02:01:22 EST


On Thu, Mar 26, 2026 at 07:05:48PM +0800, guo.wenjia23@xxxxxxxxxx wrote:
> Hi Drew,
>
> On Thu, Jan 29, 2026 at 4:28 AM Drew Fustini <fustini@xxxxxxxxxx> wrote:>
> > Add interface for CBQRI controller drivers to make use of the resctrl
> > filesystem.
> >
> > Co-developed-by: Adrien Ricciardi <aricciardi@xxxxxxxxxxxx>
> > Signed-off-by: Adrien Ricciardi <aricciardi@xxxxxxxxxxxx>
> > Signed-off-by: Drew Fustini <fustini@xxxxxxxxxx>
> > ---
> > arch/riscv/kernel/qos/qos_resctrl.c | 1192 +++++++++++++++++++++++++++++++++++
> > 1 file changed, 1192 insertions(+)
> >
> > ...
> >
> > +
> > +int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
> > + u32 closid, enum resctrl_conf_type t, u32 cfg_val)
> > +{
> > + struct cbqri_controller *ctrl;
> > + struct cbqri_resctrl_dom *dom;
> > + struct cbqri_config cfg;
> > + int err = 0;
> > +
> > + dom = container_of(d, struct cbqri_resctrl_dom, resctrl_ctrl_dom);
> > + ctrl = dom->hw_ctrl;
> > +
> > + if (!r->alloc_capable)
> > + return -EINVAL;
> > +
> > + switch (r->rid) {
> > + case RDT_RESOURCE_L2:
> > + case RDT_RESOURCE_L3:
> > + cfg.cbm = cfg_val;
> > + err = cbqri_apply_cache_config(dom, closid, t, &cfg);
> > + break;
> > + case RDT_RESOURCE_MBA:
> > + /* covert from percentage to bandwidth blocks */
> > + cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;
>
> Should use bc.mrbwb to calculate rbwb?
> I think bc.nbwblks represent the available bw blks in the controller.
> It should should decrease as they are allocated.

The resctrl MBA resource is supposed to be the percentage of total
memory bandwidth. nbwblks is the total number of bandwidth blocks, so I
think the existing calucation is correct.

>From the example SoC configuration, the number of bandwidth blocks is
1024, and mrbwb is meant to be 80% of nbwblks which is 819.

Setting MB to 80% in schemata would yield: 80 * 1024 / 100 = 819

Thanks,
Drew