[RFC PATCH 22/31] fs/resctrl: Add region-based control names and resctrl_ctrl_name_region()
From: Chen Yu
Date: Sun Aug 02 2026 - 12:20:12 EST
ERDT exposes per-memory-region bandwidth allocation controls, where each
region has an optimal (OPT), minimum (MIN) and maximum (MAX) control.
Extend enum resctrl_ctrl_name with the REGION<n>_{OPT,MIN,MAX} names (and
their string forms). These enumerators are only assigned to a control when
arch code adds a region control to rdt_resource::controls, which happens
only when the hardware supports ERDT (erdt_cpu_has()); on other platforms
they are simply unused.
Add resctrl_ctrl_name_region() so that the architecture code can retrieve
the control name for a given region and control type when creating the
corresponding controllers.
Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
---
fs/resctrl/ctrlmondata.c | 12 ++++++++++++
include/linux/resctrl.h | 29 ++++++++++++++++++++++++++++-
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/fs/resctrl/ctrlmondata.c b/fs/resctrl/ctrlmondata.c
index 74fa1215e8b2..d65036f7079e 100644
--- a/fs/resctrl/ctrlmondata.c
+++ b/fs/resctrl/ctrlmondata.c
@@ -304,6 +304,18 @@ static const char * const resctrl_ctrl_name[] = {
[RESCTRL_CTRL_NAME_DEF] = "",
[RESCTRL_CTRL_NAME_MIN] = "MIN",
[RESCTRL_CTRL_NAME_MAX] = "MAX",
+ [RESCTRL_CTRL_NAME_REGION0_OPT] = "REGION0_OPT",
+ [RESCTRL_CTRL_NAME_REGION0_MIN] = "REGION0_MIN",
+ [RESCTRL_CTRL_NAME_REGION0_MAX] = "REGION0_MAX",
+ [RESCTRL_CTRL_NAME_REGION1_OPT] = "REGION1_OPT",
+ [RESCTRL_CTRL_NAME_REGION1_MIN] = "REGION1_MIN",
+ [RESCTRL_CTRL_NAME_REGION1_MAX] = "REGION1_MAX",
+ [RESCTRL_CTRL_NAME_REGION2_OPT] = "REGION2_OPT",
+ [RESCTRL_CTRL_NAME_REGION2_MIN] = "REGION2_MIN",
+ [RESCTRL_CTRL_NAME_REGION2_MAX] = "REGION2_MAX",
+ [RESCTRL_CTRL_NAME_REGION3_OPT] = "REGION3_OPT",
+ [RESCTRL_CTRL_NAME_REGION3_MIN] = "REGION3_MIN",
+ [RESCTRL_CTRL_NAME_REGION3_MAX] = "REGION3_MAX",
};
const char *resctrl_ctrl_name_str(enum resctrl_ctrl_name name)
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 7bbda28baccf..3969db01f4cc 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -348,14 +348,41 @@ struct resctrl_mon {
* has the same name as the resource.
* @RESCTRL_CTRL_NAME_MIN: "MIN"
* @RESCTRL_CTRL_NAME_MAX: "MAX"
+ *
+ * The REGION* names describe the region based bandwidth allocation controls of
+ * each memory region has an optimal (OPT), minimum (MIN) andcmaximum (MAX) control.
+ * They are only ever assigned to a control when arch code adds a region control
+ * to rdt_resource::controls, which happens only when the hardware supports ERDT
+ * (erdt_cpu_has()); on other platforms these enumerators are simply unused.
*/
enum resctrl_ctrl_name {
RESCTRL_CTRL_NAME_DEF,
RESCTRL_CTRL_NAME_MIN,
RESCTRL_CTRL_NAME_MAX,
- RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_MAX
+ RESCTRL_CTRL_NAME_REGION0_OPT,
+ RESCTRL_CTRL_NAME_REGION0_MIN,
+ RESCTRL_CTRL_NAME_REGION0_MAX,
+ RESCTRL_CTRL_NAME_REGION1_OPT,
+ RESCTRL_CTRL_NAME_REGION1_MIN,
+ RESCTRL_CTRL_NAME_REGION1_MAX,
+ RESCTRL_CTRL_NAME_REGION2_OPT,
+ RESCTRL_CTRL_NAME_REGION2_MIN,
+ RESCTRL_CTRL_NAME_REGION2_MAX,
+ RESCTRL_CTRL_NAME_REGION3_OPT,
+ RESCTRL_CTRL_NAME_REGION3_MIN,
+ RESCTRL_CTRL_NAME_REGION3_MAX,
+ RESCTRL_CTRL_NAME_LAST = RESCTRL_CTRL_NAME_REGION3_MAX
};
+#define RESCTRL_CTRL_REGION_NR_CTRLS 3
+
+static inline enum resctrl_ctrl_name
+resctrl_ctrl_name_region(unsigned int region, unsigned int type)
+{
+ return RESCTRL_CTRL_NAME_REGION0_OPT +
+ region * RESCTRL_CTRL_REGION_NR_CTRLS + type;
+}
+
/* Flags for rdt_resource::flags and resctrl_ctrl::flags */
#define RESCTRL_CTRL_FLAG_LINEAR BIT(0)
#define RESCTRL_CTRL_FLAG_SPARSE_BITMASKS BIT(1)
--
2.43.0