Re: [PATCH RFC v3 06/11] RISC-V: QoS: add resctrl setup and domain management

guo.wenjia23 at zte.com.cn guo.wenjia23 at zte.com.cn
Fri Apr 17 03:52:27 PDT 2026


Hi Drew,

On Wed, Apr 15, 2026 at 9:57 AM Drew Fustini <fustini at kernel.org> wrote:

> Add the setup and domain management layer: domain allocation
> (qos_new_domain), controller value initialization
> (qos_init_domain_ctrlval), resource struct initialization for cache and
> bandwidth resources, domain registration with the resctrl filesystem
> (qos_resctrl_add_controller_domain), and the top-level setup function
> (qos_resctrl_setup) that probes all controllers and calls resctrl_init().
>
> Also add qos_resctrl_online_cpu() and qos_resctrl_offline_cpu() for CPU
> hotplug integration.
>
> Co-developed-by: Adrien Ricciardi <aricciardi at baylibre.com>
> Signed-off-by: Adrien Ricciardi <aricciardi at baylibre.com>
> Signed-off-by: Drew Fustini <fustini at kernel.org>
> ---
>  arch/riscv/kernel/qos/qos_resctrl.c | 295 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 294 insertions(+), 1 deletion(-)
>
> diff --git a/arch/riscv/kernel/qos/qos_resctrl.c b/arch/riscv/kernel/qos/qos_resctrl.c
> index a4a120f89840..8d7e3b0abb75 100644
> --- a/arch/riscv/kernel/qos/qos_resctrl.c
> +++ b/arch/riscv/kernel/qos/qos_resctrl.c
> @@ -675,7 +675,23 @@ void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_l3_mon_domai
>  
>  void resctrl_arch_reset_all_ctrls(struct rdt_resource *r)
>  {
> -    /* not implemented for the RISC-V resctrl implementation */
> +    struct cbqri_resctrl_res *hw_res;
> +    struct rdt_ctrl_domain *d;
> +    enum resctrl_conf_type t;
> +    u32 default_ctrl;
> +    int i;
> +
> +    lockdep_assert_cpus_held();
> +
> +    hw_res = container_of(r, struct cbqri_resctrl_res, resctrl_res);
> +    default_ctrl = resctrl_get_default_ctrl(r);
> +
> +    list_for_each_entry(d, &r->ctrl_domains, hdr.list) {
> +        for (i = 0; i < hw_res->max_rcid; i++) {
> +            for (t = 0; t < CDP_NUM_TYPES; t++)
> +                resctrl_arch_update_one(r, d, i, t, default_ctrl);

For the bw controller, default_ctrl = max_bw, and resctrl_arch_update_one will set the rbwb of all RCIDs to max_bw. 
According to the spec: The sum of Rbwb allocated across all rcids must not exceed MRBWB value. 

Does this conflict with the spec?

> +        }
> +    }
>  }
>  
>  void resctrl_arch_pre_mount(void)
> @@ -797,3 +813,280 @@ u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_ctrl_domain *d,
>      spin_unlock(&ctrl->lock);
>      return val;
>  }
> +
> +static struct rdt_ctrl_domain *qos_new_domain(struct cbqri_controller *ctrl)
> +{
> +    struct cbqri_resctrl_dom *hw_dom;
> +    struct rdt_ctrl_domain *domain;
> +
> +    hw_dom = kzalloc_obj(*hw_dom, GFP_KERNEL);
> +    if (!hw_dom)
> +        return NULL;
> +
> +    /* associate this cbqri_controller with the domain */
> +    hw_dom->hw_ctrl = ctrl;
> +
> +    /* the rdt_domain struct from inside the cbqri_resctrl_dom struct */
> +    domain = &hw_dom->resctrl_ctrl_dom;
> +
> +    INIT_LIST_HEAD(&domain->hdr.list);
> +
> +    return domain;
> +}
> +
> +static int qos_init_domain_ctrlval(struct rdt_resource *r, struct rdt_ctrl_domain *d)
> +{
> +    struct cbqri_resctrl_res *hw_res;
> +    int err = 0;
> +    int i;
> +
> +    hw_res = container_of(r, struct cbqri_resctrl_res, resctrl_res);
> +
> +    for (i = 0; i < hw_res->max_rcid; i++) {
> +        err = resctrl_arch_update_one(r, d, i, 0, resctrl_get_default_ctrl(r));

Also set rbwb of all RCIDs to max_bw. Does this also conflict with the spec?

> +        if (err)
> +            return err;
> +    }
> +    return 0;
> +}
> +


Thanks,
Wenjia



More information about the linux-riscv mailing list