Re: [PATCH RFC v3 05/11] RISC-V: QoS: add resctrl arch callbacks for CBQRI controllers

Reinette Chatre
2026-04-30T23:52:20Z

Hi Drew,

On 4/30/26 4:37 PM, Drew Fustini wrote:
> On Thu, Apr 30, 2026 at 04:17:22PM -0700, Reinette Chatre wrote:
>> Hi Drew,
>>
>> On 4/14/26 6:53 PM, Drew Fustini wrote:
>>
>>> +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:
>>> + /* convert from percentage to bandwidth blocks */
>>> + cfg.rbwb = cfg_val * ctrl->bc.nbwblks / 100;
>>> + cfg.rbwb = min_t(u64, cfg.rbwb, ctrl->bc.mrbwb);
>>> + err = cbqri_apply_bw_config(dom, closid, t, &cfg);
>>
>> (Earlier comment wondered about whether rbwb cannot just be provided
>> directly to cbqri_apply_bw_config().)
>>
>> Apart from that it looks like this can benefit from "emulated controls"
>> that we mused about at https://lore.kernel.org/lkml/e788ca62-ec63-4552-978b-9569f369afd5@intel.com/
>>
>> At this time this MBA resource is constrained by the 1% steps that the
>> default MB control supports and clearly it is emulated with a control that
>> can support finer granularities. I am currently working on a PoC of the
>> base schema descriptions on which the support for emulated controls can
>> be built that should be able to expose full hardware capability.
>>
>> Reinette
>
> Thank you for your review. I have been working on a large overhaul to
> the series in v4 and was about to send it. I finally realized the
> sematic mismatch between resctl MB resource and what the RISC-V CBQRI
> spec offers. I decided to create MB_MIN for reserved bandwidth and
> MB_WGHT (weight) for shared bandwidth porpotional weight.
>
> I didn't expect adding two new resources to be the best solution but I
> wanted to offer something tangible to move the discussion forward. I
> look forward to your proof of concept as I expect I can then build
> proper support CBQRI bandwidth allocation (reservation and proportional
> share) on top of that.

Creating multiple resources to support discussion seems reasonable.
Part of what my PoC introduces is that a single resource can have multiple
controls. This sounds relevant here.
My initial PoC ended up giving the architecture too much control over
the user interface in deciding how these controls are presented to the user.
Things like this have been ok so far with the architectures behaving well (for
example, all architectures making sure to name their cache resources
"L2" and "L3" to have these appear identical to user space), but resctrl fs
can make this simpler. This does mean that resctrl fs would need to be "taught"
about new controls like "WGHT"/weight. I am reworking the series as we speak
so that we can use it to discuss more.

Reinette