* [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw()
2026-07-06 16:06 [PATCH v4 0/3] x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch Ben Horgan
@ 2026-07-06 16:06 ` Ben Horgan
2026-07-06 21:33 ` Reinette Chatre
2026-07-06 16:06 ` [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw() Ben Horgan
2026-07-06 16:06 ` [PATCH v4 3/3] fs/resctrl: Factor MBA parse-time conversion to be per-arch Ben Horgan
2 siblings, 1 reply; 8+ messages in thread
From: Ben Horgan @ 2026-07-06 16:06 UTC (permalink / raw)
To: ben.horgan
Cc: james.morse, reinette.chatre, fenghuay, linux-kernel,
linux-arm-kernel, tglx, mingo, bp, dave.hansen, hpa, corbet, x86,
linux-doc, dave.martin
On MPAM systems the rounding behaviour of the MBA control would be improved
if the rounding in the fs/resctrl code is removed but this is not the
case for x86. To allow any rounding or conversion of the bandwidth value
provided by the user to be specified by the arch code a new arch hook is
required.
Introduce resctrl_arch_preconvert_bw(), and add its x86 implementation.
This is currently unused in resctrl but when plumbed in it will replace the
call to roundup() in bw_validate().
Signed-off-by: Dave Martin <dave.martin@arm.com>
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
Changes since Dave's v2:
Split from larger patch and add commit message
Update kernel-doc (Reinette)
Changes since v3:
Swap parameter order (Reinette)
Change summary prefix include fs/resctrl (Reinette)
val -> @val
Add Reinette's R-b
---
arch/x86/kernel/cpu/resctrl/ctrlmondata.c | 6 ++++++
include/linux/resctrl.h | 19 +++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
index b20e705606b8..81a08526d3d1 100644
--- a/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
+++ b/arch/x86/kernel/cpu/resctrl/ctrlmondata.c
@@ -16,9 +16,15 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/cpu.h>
+#include <linux/math.h>
#include "internal.h"
+u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val)
+{
+ return roundup(val, (unsigned long)r->membw.bw_gran);
+}
+
int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_ctrl_domain *d,
u32 closid, enum resctrl_conf_type t, u32 cfg_val)
{
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 73ff522448a0..1ebd4b90043a 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -504,6 +504,25 @@ bool resctrl_arch_mbm_cntr_assign_enabled(struct rdt_resource *r);
*/
int resctrl_arch_mbm_cntr_assign_set(struct rdt_resource *r, bool enable);
+/**
+ * resctrl_arch_preconvert_bw() - Prepare bandwidth control value for arch use.
+ * @r: Resource whose schema was written.
+ * @val: Bandwidth control value written to the schemata file by userspace.
+ *
+ * Convert the user provided bandwidth control value to an appropriate form for
+ * consumption by the hardware driver for resource @r. Converted value is stored
+ * in rdt_ctrl_domain::staged_config[] for later consumption by
+ * resctrl_arch_update_domains(). Is not called when MBA software controller is
+ * enabled.
+ *
+ * Architectures for which this pre-conversion hook is not useful should supply
+ * an implementation of this function that just returns @val unmodified.
+ *
+ * Return:
+ * The converted value.
+ */
+u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val);
+
/*
* Update the ctrl_val and apply this config right now.
* Must be called on one of the domain's CPUs.
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw()
2026-07-06 16:06 ` [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw() Ben Horgan
@ 2026-07-06 21:33 ` Reinette Chatre
2026-07-07 8:33 ` Ben Horgan
0 siblings, 1 reply; 8+ messages in thread
From: Reinette Chatre @ 2026-07-06 21:33 UTC (permalink / raw)
To: Ben Horgan
Cc: james.morse, fenghuay, linux-kernel, linux-arm-kernel, tglx,
mingo, bp, dave.hansen, hpa, corbet, x86, linux-doc, dave.martin
Hi Ben,
On 7/6/26 9:06 AM, Ben Horgan wrote:
> On MPAM systems the rounding behaviour of the MBA control would be improved
> if the rounding in the fs/resctrl code is removed but this is not the
> case for x86. To allow any rounding or conversion of the bandwidth value
> provided by the user to be specified by the arch code a new arch hook is
> required.
>
> Introduce resctrl_arch_preconvert_bw(), and add its x86 implementation.
> This is currently unused in resctrl but when plumbed in it will replace the
> call to roundup() in bw_validate().
>
> Signed-off-by: Dave Martin <dave.martin@arm.com>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
This chain does not look right. The first SOB is expected to be from the
author but the patch does not have Dave as author.
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
> ---
Reinette
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw()
2026-07-06 21:33 ` Reinette Chatre
@ 2026-07-07 8:33 ` Ben Horgan
0 siblings, 0 replies; 8+ messages in thread
From: Ben Horgan @ 2026-07-07 8:33 UTC (permalink / raw)
To: Reinette Chatre
Cc: james.morse, fenghuay, linux-kernel, linux-arm-kernel, tglx,
mingo, bp, dave.hansen, hpa, corbet, x86, linux-doc, dave.martin
Hi Reinette,
On 7/6/26 22:33, Reinette Chatre wrote:
> Hi Ben,
>
> On 7/6/26 9:06 AM, Ben Horgan wrote:
>> On MPAM systems the rounding behaviour of the MBA control would be improved
>> if the rounding in the fs/resctrl code is removed but this is not the
>> case for x86. To allow any rounding or conversion of the bandwidth value
>> provided by the user to be specified by the arch code a new arch hook is
>> required.
>>
>> Introduce resctrl_arch_preconvert_bw(), and add its x86 implementation.
>> This is currently unused in resctrl but when plumbed in it will replace the
>> call to roundup() in bw_validate().
>>
>> Signed-off-by: Dave Martin <dave.martin@arm.com>
>> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
>
> This chain does not look right. The first SOB is expected to be from the
> author but the patch does not have Dave as author.
Ah.. I've changed the author of this and the last patch to be Dave as he
wrote the code.
Thanks,
Ben
>
>> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
>> ---
>
> Reinette
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw()
2026-07-06 16:06 [PATCH v4 0/3] x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch Ben Horgan
2026-07-06 16:06 ` [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw() Ben Horgan
@ 2026-07-06 16:06 ` Ben Horgan
2026-07-06 21:33 ` Reinette Chatre
2026-07-06 16:06 ` [PATCH v4 3/3] fs/resctrl: Factor MBA parse-time conversion to be per-arch Ben Horgan
2 siblings, 1 reply; 8+ messages in thread
From: Ben Horgan @ 2026-07-06 16:06 UTC (permalink / raw)
To: ben.horgan
Cc: james.morse, reinette.chatre, fenghuay, linux-kernel,
linux-arm-kernel, tglx, mingo, bp, dave.hansen, hpa, corbet, x86,
linux-doc, dave.martin
resctrl rounds up the percentage value of the MBA based on the bw_gran. As
MPAM uses a binary fixed point fraction format for MBA rather than a
decimal percentage, this introduces rounding errors.
Without this additional rounding, if the user reads the value in an MB
schema and then writes it back to the schema, the value in hardware won't
change. However, with this additional rounding, this guarantee is broken
for systems with mbw_wd < 7.
resctrl is introducing resctrl_arch_preconvert_bw() to allow the arch code
to specify the conversion resctrl does to the user-provided bandwidth
value. Add the MPAM version of resctrl_arch_preconvert_bw(). This does no
conversion.
Signed-off-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
Changes since v3:
Parameter order switch (Reinette)
Add Reinette's R-b
---
drivers/resctrl/mpam_resctrl.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/resctrl/mpam_resctrl.c b/drivers/resctrl/mpam_resctrl.c
index 226ff6f532fa..e9dea8c40265 100644
--- a/drivers/resctrl/mpam_resctrl.c
+++ b/drivers/resctrl/mpam_resctrl.c
@@ -167,6 +167,11 @@ bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid)
return mpam_resctrl_controls[rid].cdp_enabled;
}
+u32 resctrl_arch_preconvert_bw(const struct rdt_resource *r, u32 val)
+{
+ return val;
+}
+
/**
* resctrl_reset_task_closids() - Reset the PARTID/PMG values for all tasks.
*
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread* Re: [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw()
2026-07-06 16:06 ` [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw() Ben Horgan
@ 2026-07-06 21:33 ` Reinette Chatre
2026-07-07 8:35 ` Ben Horgan
0 siblings, 1 reply; 8+ messages in thread
From: Reinette Chatre @ 2026-07-06 21:33 UTC (permalink / raw)
To: Ben Horgan
Cc: james.morse, fenghuay, linux-kernel, linux-arm-kernel, tglx,
mingo, bp, dave.hansen, hpa, corbet, x86, linux-doc, dave.martin
Hi Ben,
On 7/6/26 9:06 AM, Ben Horgan wrote:
> resctrl rounds up the percentage value of the MBA based on the bw_gran. As
> MPAM uses a binary fixed point fraction format for MBA rather than a
> decimal percentage, this introduces rounding errors.
>
> Without this additional rounding, if the user reads the value in an MB
> schema and then writes it back to the schema, the value in hardware won't
> change. However, with this additional rounding, this guarantee is broken
> for systems with mbw_wd < 7.
>
> resctrl is introducing resctrl_arch_preconvert_bw() to allow the arch code
> to specify the conversion resctrl does to the user-provided bandwidth
> value. Add the MPAM version of resctrl_arch_preconvert_bw(). This does no
> conversion.
>
> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
>
Unfortunately the "---" separator is missing here.
> Changes since v3:
> Parameter order switch (Reinette)
> Add Reinette's R-b
> ---
Reinette
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw()
2026-07-06 21:33 ` Reinette Chatre
@ 2026-07-07 8:35 ` Ben Horgan
0 siblings, 0 replies; 8+ messages in thread
From: Ben Horgan @ 2026-07-07 8:35 UTC (permalink / raw)
To: Reinette Chatre
Cc: james.morse, fenghuay, linux-kernel, linux-arm-kernel, tglx,
mingo, bp, dave.hansen, hpa, corbet, x86, linux-doc, dave.martin
Hi Reinette,
On 7/6/26 22:33, Reinette Chatre wrote:
> Hi Ben,
>
> On 7/6/26 9:06 AM, Ben Horgan wrote:
>> resctrl rounds up the percentage value of the MBA based on the bw_gran. As
>> MPAM uses a binary fixed point fraction format for MBA rather than a
>> decimal percentage, this introduces rounding errors.
>>
>> Without this additional rounding, if the user reads the value in an MB
>> schema and then writes it back to the schema, the value in hardware won't
>> change. However, with this additional rounding, this guarantee is broken
>> for systems with mbw_wd < 7.
>>
>> resctrl is introducing resctrl_arch_preconvert_bw() to allow the arch code
>> to specify the conversion resctrl does to the user-provided bandwidth
>> value. Add the MPAM version of resctrl_arch_preconvert_bw(). This does no
>> conversion.
>>
>> Signed-off-by: Ben Horgan <ben.horgan@arm.com>
>> Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
>>
>
> Unfortunately the "---" separator is missing here.
Another silly mistake.. sorry about that. I've corrected locally and
will send a respin in a day or two.
Thanks,
Ben
>
>> Changes since v3:
>> Parameter order switch (Reinette)
>> Add Reinette's R-b
>> ---
> Reinette
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] fs/resctrl: Factor MBA parse-time conversion to be per-arch
2026-07-06 16:06 [PATCH v4 0/3] x86,fs/resctrl,arm_mpam: Factor MBA parse-time conversion to be per-arch Ben Horgan
2026-07-06 16:06 ` [PATCH v4 1/3] x86,fs/resctrl: Add resctrl_arch_preconvert_bw() Ben Horgan
2026-07-06 16:06 ` [PATCH v4 2/3] arm_mpam: resctrl: Add pass-through resctrl_arch_preconvert_bw() Ben Horgan
@ 2026-07-06 16:06 ` Ben Horgan
2 siblings, 0 replies; 8+ messages in thread
From: Ben Horgan @ 2026-07-06 16:06 UTC (permalink / raw)
To: ben.horgan
Cc: james.morse, reinette.chatre, fenghuay, linux-kernel,
linux-arm-kernel, tglx, mingo, bp, dave.hansen, hpa, corbet, x86,
linux-doc, dave.martin, Dave Martin, Ben Horgan
From: Dave Martin <Dave.Martin@arm.com>
The control value parser for the MB resource currently coerces the memory
bandwidth percentage value from userspace to be an exact multiple of the
rdt_resource::resctrl_membw::bw_gran parameter.
On MPAM systems, this results in somewhat worse-than-worst-case rounding, since
the bandwidth granularity advertised to resctrl by the MPAM driver is in general
only an approximation to the actual hardware granularity on these systems, and
the hardware bandwidth allocation control value is not natively a percentage --
necessitating a further conversion in the resctrl_arch_update_domains() path,
regardless of the conversion done at parse time.
For MPAM and x86 use their custom pre-prepared parse-time conversion,
resctrl_arch_preconvert_bw(). This will avoid accumulated error from rounding
the value twice on MPAM systems. For x86 systems there is no functional change.
Clarify the documentation, but avoid overly exact promises.
Clamping to bw_min and bw_max still feels generic: leave it in the core code,
for now.
[ BH: Split out x86 specific changes ]
Signed-off-by: Dave Martin <Dave.Martin@arm.com>
Signed-off-by: Ben Horgan <Ben.Horgan@arm.com>
Reviewed-by: Ben Horgan <ben.horgan@arm.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
Changes since v3:
Parameter order swap (Reinette)
Reflow commit message to use 80 characters (Reinette)
Adjust comment line length (Reinette)
Add Reinette's R-b
---
Documentation/filesystems/resctrl.rst | 17 +++++++++--------
fs/resctrl/ctrlmondata.c | 6 +++---
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/Documentation/filesystems/resctrl.rst b/Documentation/filesystems/resctrl.rst
index e4b66af55ffb..e4448c20c72e 100644
--- a/Documentation/filesystems/resctrl.rst
+++ b/Documentation/filesystems/resctrl.rst
@@ -236,12 +236,11 @@ with respect to allocation:
user can request.
"bandwidth_gran":
- The granularity in which the memory bandwidth
- percentage is allocated. The allocated
- b/w percentage is rounded off to the next
- control step available on the hardware. The
- available bandwidth control steps are:
- min_bandwidth + N * bandwidth_gran.
+ The approximate granularity in which the memory bandwidth
+ percentage is allocated. The allocated bandwidth percentage
+ is rounded up to the next control step available on the
+ hardware. The available hardware steps are no larger than
+ this value.
"delay_linear":
Indicates if the delay scale is linear or
@@ -881,8 +880,10 @@ The minimum bandwidth percentage value for each cpu model is predefined
and can be looked up through "info/MB/min_bandwidth". The bandwidth
granularity that is allocated is also dependent on the cpu model and can
be looked up at "info/MB/bandwidth_gran". The available bandwidth
-control steps are: min_bw + N * bw_gran. Intermediate values are rounded
-to the next control step available on the hardware.
+control steps are, approximately, min_bw + N * bw_gran. The steps may
+appear irregular due to rounding to an exact percentage: bw_gran is the
+maximum interval between the percentage values corresponding to any two
+adjacent steps in the hardware.
The bandwidth throttling is a core specific mechanism on some of Intel
SKUs. Using a high bandwidth and a low bandwidth setting on two threads
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 9a7dfc48cb2e..62c9c6b24d54 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -37,8 +37,8 @@ typedef int (ctrlval_parser_t)(struct rdt_parse_data *data,
/*
* Check whether MBA bandwidth percentage value is correct. The value is
* checked against the minimum and max bandwidth values specified by the
- * hardware. The allocated bandwidth percentage is rounded to the next
- * control step available on the hardware.
+ * hardware. The allocated bandwidth percentage is converted as appropriate
+ * for consumption by the specific hardware driver.
*/
static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
{
@@ -71,7 +71,7 @@ static bool bw_validate(char *buf, u32 *data, struct rdt_resource *r)
return false;
}
- *data = roundup(bw, (unsigned long)r->membw.bw_gran);
+ *data = resctrl_arch_preconvert_bw(r, bw);
return true;
}
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread