[PATCH v2 02/16] fs, x86/resctrl: Add architecture routines for kernel mode initialization

Babu Moger
2026-03-12T20:37:40Z

Implement the resctrl kernel mode (kmode) arch initialization.

- Add resctrl_arch_get_kmode_cfg() to fill the default kernel mode
(INHERIT_CTRL_AND_MON). This can be extended later (e.g. for PLZA) to set
additional modes.

- Add global resctrl_kcfg and resctrl_kmode_init() to initialize default
values.

Signed-off-by: Babu Moger <babu.moger@amd.com>
---
v2: New patch to handle PLZA interfaces with /sys/fs/resctrl/info/ directory.
https://lore.kernel.org/lkml/2ab556af-095b-422b-9396-f845c6fd0342@intel.com/
---
arch/x86/kernel/cpu/resctrl/core.c | 7 +++++++
fs/resctrl/rdtgroup.c | 10 ++++++++++
2 files changed, 17 insertions(+)

diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 7667cf7c4e94..4c3ab2d93909 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -892,6 +892,13 @@ bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt)
}
}

+void resctrl_arch_get_kmode_cfg(struct resctrl_kmode_cfg *kcfg)
+{
+ kcfg->kmode = INHERIT_CTRL_AND_MON;
+ kcfg->kmode_cur = INHERIT_CTRL_AND_MON;
+ kcfg->k_rdtgrp = NULL;
+}
+
static __init bool get_mem_config(void)
{
struct rdt_hw_resource *hw_res = &rdt_resources_all[RDT_RESOURCE_MBA];
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 5da305bd36c9..9d6d74af4874 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -76,6 +76,9 @@ static void rdtgroup_destroy_root(void);

struct dentry *debugfs_resctrl;

+/* Current resctrl kernel mode config (kmode, kmode_cur, k_rdtgrp). */
+struct resctrl_kmode_cfg resctrl_kcfg;
+
/*
* Memory bandwidth monitoring event to use for the default CTRL_MON group
* and each new CTRL_MON group created by the user. Only relevant when
@@ -2204,6 +2207,11 @@ static void io_alloc_init(void)
}
}

+static void resctrl_kmode_init(void)
+{
+ resctrl_arch_get_kmode_cfg(&resctrl_kcfg);
+}
+
void resctrl_file_fflags_init(const char *config, unsigned long fflags)
{
struct rftype *rft;
@@ -4554,6 +4562,8 @@ int resctrl_init(void)

io_alloc_init();

+ resctrl_kmode_init();
+
ret = resctrl_l3_mon_resource_init();
if (ret)
return ret;
--
2.43.0