Re: [PATCH v2 1/5] x86,fs/resctrl: Remove unused non-linear bandwidth delay mapping
From: Jinjie Ruan
Date: Tue Oct 27 2026 - 04:08:51 EST
在 2026/10/8 5:06, Reinette Chatre 写道:
> Intel MBA throttles memory bandwidth with delay values, while resctrl
> exposes memory bandwidth to user space as a percentage. When delay values
> are linear there is a direct mapping between the two. Support for
> non-linear delay values would need a pre-calibrated table mapping
> percentages to delay values.
>
> Commit
>
> 05b93417ce5b ("x86/intel_rdt/mba: Add primary support for Memory Bandwidth Allocation (MBA)")
>
> added a placeholder for such a table to the resctrl_membw structure, but
> the table was never populated and never read. rdt_get_mb_table(), which
> would provide it, always fails. As a result, an Intel MBA resource with
> non-linear delay values is never marked as capable of allocation, and its
> control values are never written to hardware.
>
> Remove the unused mapping table and fold the linear percentage-to-delay
> conversion into the function that writes the control values to hardware.
>
> Keep the check that delay values are linear as a defensive measure in
> preparation for supporting multiple controls, which turns the memory
> bandwidth control into a generic scalar control that indicates whether it
> requires linear values.
>
> Signed-off-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
> Reviewed-by: Chen Yu <yu.c.chen@xxxxxxxxx>
> ---
> Changes since RFC v1:
> - Also drop separate delay_bw_map() and instead integrate the only
> mapping to when control value is written.
>
> Changes since RFC v2:
> - Rework changelog.
>
> Changes since v1:
> - Rewrite changelog, fix subject prefix.
> - Match error message about linear support with similar message during
> enumeration added in next patch.
> - Add Chenyu's Reviewed-by tag
> ---
> arch/x86/kernel/cpu/resctrl/core.c | 23 +++++++----------------
> include/linux/resctrl.h | 2 --
> 2 files changed, 7 insertions(+), 18 deletions(-)
>
> diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
> index 55214d6fdc49..f9677e52790e 100644
> --- a/arch/x86/kernel/cpu/resctrl/core.c
> +++ b/arch/x86/kernel/cpu/resctrl/core.c
> @@ -323,29 +323,20 @@ static void mba_wrmsr_amd(struct msr_param *m)
> wrmsrq(hw_res->msr_base + i, hw_dom->ctrl_val[i]);
> }
>
> -/*
> - * Map the memory b/w percentage value to delay values
> - * that can be written to QOS_MSRs.
> - * There are currently no SKUs which support non linear delay values.
> - */
> -static u32 delay_bw_map(unsigned long bw, struct rdt_resource *r)
> -{
> - if (r->membw.delay_linear)
> - return MAX_MBA_BW - bw;
> -
> - pr_warn_once("Non Linear delay-bw map not supported but queried\n");
> - return MAX_MBA_BW;
> -}
> -
> static void mba_wrmsr_intel(struct msr_param *m)
> {
> struct rdt_hw_ctrl_domain *hw_dom = resctrl_to_arch_ctrl_dom(m->dom);
> struct rdt_hw_resource *hw_res = resctrl_to_arch_res(m->res);
> unsigned int i;
>
> - /* Write the delay values for mba. */
> + if (!m->res->membw.delay_linear) {
> + pr_warn_once("Non-linear MBA delay values not supported\n");
> + return;
> + }
> +
> + /* Program bandwidth percentage mapped to linear delay value. */
> for (i = m->low; i < m->high; i++)
> - wrmsrq(hw_res->msr_base + i, delay_bw_map(hw_dom->ctrl_val[i], m->res));
> + wrmsrq(hw_res->msr_base + i, MAX_MBA_BW - hw_dom->ctrl_val[i]);
LGTM
Reviewed-by: Jinjie Ruan <ruanjinjie@xxxxxxxxxx>
> }
>
> static void cat_wrmsr(struct msr_param *m)
> diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
> index 10dfdca7f4bf..b63dc62690ca 100644
> --- a/include/linux/resctrl.h
> +++ b/include/linux/resctrl.h
> @@ -253,7 +253,6 @@ enum membw_throttle_mode {
> * @throttle_mode: Bandwidth throttling mode when threads request
> * different memory bandwidths
> * @mba_sc: True if MBA software controller(mba_sc) is enabled
> - * @mb_map: Mapping of memory B/W percentage to memory B/W delay
> */
> struct resctrl_membw {
> u32 min_bw;
> @@ -263,7 +262,6 @@ struct resctrl_membw {
> bool arch_needs_linear;
> enum membw_throttle_mode throttle_mode;
> bool mba_sc;
> - u32 *mb_map;
> };
>
> struct resctrl_schema;
--
Best regards,
Jinjie