[PATCH RFC v1 1/6] resctrl: wire MB_MAXHLM schemata parsing and group setup
From: Fenghua Yu
Date: Mon Nov 09 2026 - 16:32:50 EST
The hard-limit control is a 0/1 value on the MBA resource, not a
separate schemata resource. Parse MB_MAXHLM in the bandwidth parser,
reject values other than 0 and 1, and initialize new groups with the
hard limit off.
Signed-off-by: Fenghua Yu <fenghuay@xxxxxxxxxx>
---
fs/resctrl/ctrlmondata.c | 35 +++++++++++++++++++++++++++++++++++
fs/resctrl/rdtgroup.c | 17 +++++++++++++++++
include/linux/resctrl.h | 8 +++++++-
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 77a2f2e877a6..9111b0130783 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -62,6 +62,29 @@ static struct resctrl_ctrl_priv resctrl_ctrl_priv_all[] = {
},
};
+static bool mb_maxhlm_validate(char *buf, u32 *data, struct rdt_resource *r,
+ struct resctrl_ctrl *ctrl)
+{
+ int ret;
+ u32 mb_maxhlm;
+
+ ret = kstrtou32(buf, 10, &mb_maxhlm);
+ if (ret) {
+ rdt_last_cmd_printf("Invalid MB_MAXHLM value %s\n", buf);
+ return false;
+ }
+
+ if (mb_maxhlm != 0 && mb_maxhlm != 1) {
+ rdt_last_cmd_printf("MB_MAXHLM value %u isn't 0/1\n",
+ mb_maxhlm);
+ return false;
+ }
+
+ *data = mb_maxhlm;
+
+ return true;
+}
+
/*
* Iterator finding enabled controls.
* Dynamically traverses controls based on active control mode.
@@ -165,6 +188,17 @@ static int parse_bw(struct rdt_parse_data *data, struct rdt_resource_final *f,
return -EINVAL;
}
+ /* Parse mb_maxhlm line */
+ if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM) {
+ if (!mb_maxhlm_validate(data->buf, &bw_val, r, ctrl))
+ return -EINVAL;
+
+ cfg->new_ctrl = bw_val;
+ cfg->have_new_ctrl = true;
+ return 0;
+ }
+
+ /* Parse mb line */
if (!bw_validate(data->buf, &bw_val, r, ctrl))
return -EINVAL;
@@ -362,6 +396,7 @@ static const char * const resctrl_ctrl_name[] = {
[RESCTRL_CTRL_NAME_NODE] = "NODE",
[RESCTRL_CTRL_NAME_REGION0_MIN] = "REGION0_MIN",
[RESCTRL_CTRL_NAME_REGION0_MAX] = "REGION0_MAX",
+ [RESCTRL_CTRL_NAME_MAXHLM] = "MAXHLM",
};
const char *resctrl_ctrl_name_str(enum resctrl_ctrl_name name)
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index a16e35b587c4..01e69d0d9e96 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4401,6 +4401,19 @@ static void rdtgroup_init_mba(struct rdt_resource *r, struct resctrl_ctrl *ctrl,
}
}
+/* Initialize the MB MAXHLM control with default hardlim off (0). */
+static void rdtgroup_init_mb_hlim(struct resctrl_ctrl *ctrl)
+{
+ struct resctrl_staged_config *cfg;
+ struct rdt_ctrl_domain *d;
+
+ list_for_each_entry(d, &ctrl->domains, hdr.list) {
+ cfg = &d->staged_config[CDP_NONE];
+ cfg->new_ctrl = 0;
+ cfg->have_new_ctrl = true;
+ }
+}
+
/* Initialize the RDT group's allocations. */
static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
{
@@ -4416,6 +4429,10 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp)
for_each_enabled_ctrl(ctrl, r) {
if (r->rid == RDT_RESOURCE_MBA ||
r->rid == RDT_RESOURCE_SMBA) {
+ if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM) {
+ rdtgroup_init_mb_hlim(ctrl);
+ continue;
+ }
rdtgroup_init_mba(r, ctrl, rdtgrp->closid);
if (is_mba_sc(r, ctrl))
continue;
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 3c4675656b51..5711154145f8 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -402,6 +402,7 @@ struct resctrl_mon {
* line is "MB_NODE".
* @RESCTRL_CTRL_NAME_REGION0_MIN: "REGION0_MIN"
* @RESCTRL_CTRL_NAME_REGION0_MAX: "REGION0_MAX"
+ * @RESCTRL_CTRL_NAME_MAXHLM: "MAXHLM"
*/
enum resctrl_ctrl_name {
RESCTRL_CTRL_NAME_DEF,
@@ -410,7 +411,8 @@ enum resctrl_ctrl_name {
RESCTRL_CTRL_NAME_NODE,
RESCTRL_CTRL_NAME_REGION0_MIN,
RESCTRL_CTRL_NAME_REGION0_MAX,
- RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_REGION0_MAX
+ RESCTRL_CTRL_NAME_MAXHLM,
+ RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_MAXHLM
};
/**
@@ -616,6 +618,10 @@ static inline u32 resctrl_get_default_ctrlval(struct resctrl_ctrl *ctrl)
*/
return BIT_MASK(ctrl->bitmap.cbm_len) - 1;
case RESCTRL_CTRL_SCALAR:
+ /* The hard-limit toggle defaults to off. */
+ if (ctrl->name == RESCTRL_CTRL_NAME_MAXHLM)
+ return 0;
+
return ctrl->scalar.reset_val;
}
--
2.53.0