[RFC PATCH 29/31] fs/resctrl: Expose emulation controllers in a resource_schemata subdir

From: Chen Yu

Date: Sun Aug 02 2026 - 12:20:39 EST


The legacy MBA default controller is emulated by other controls (for
ERDT, "MB" is emulated by the MAX control of every memory region).

When a control is emulated (resctrl_ctrl::emul is not empty), do not
expose the control's own properties. Keep the control's own
resource_schemata directory and, underneath it, create a sub-directory
named after each emulation controller that holds that emulation
controller's properties. For example:

[root@ MB]# tree resource_schemata/
resource_schemata/
├── MB
│ ├── MB_REGION0_MAX
│ │ ├── max
│ │ ├── min
│ │ ├── resolution
│ │ ├── scale
│ │ ├── scope
│ │ ├── tolerance
│ │ ├── type
│ │ └── unit
│ └── MB_REGION1_MAX
│ ├── max
│ ├── min
│ ├── resolution
│ ├── scale
│ ├── scope
│ ├── tolerance
│ ├── type
│ └── unit

Controls without an emulation controller keep exposing their own
properties directly.

Signed-off-by: Chen Yu <yu.c.chen@xxxxxxxxx>
---
fs/resctrl/rdtgroup.c | 31 +++++++++++++++++++++++++++----
1 file changed, 27 insertions(+), 4 deletions(-)

diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index c1aac0dcd332..31bea5a9833b 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -2741,13 +2741,36 @@ static int resctrl_mkdir_schemata_dir(struct kernfs_node *kn,
if (IS_ERR(kn_ctrl))
return PTR_ERR(kn_ctrl);

- ret = rdtgroup_kn_set_ugid(kn_subdir);
+ ret = rdtgroup_kn_set_ugid(kn_ctrl);
if (ret)
return ret;

- ret = resctrl_add_ctrl_files(kn_ctrl, ctrl);
- if (ret)
- return ret;
+ if (!list_empty(&ctrl->emul)) {
+ struct kernfs_node *kn_emul;
+ struct resctrl_ctrl *emul;
+
+ for_each_emul_ctrl(emul, ctrl) {
+ snprintf(ctrl_full_name, sizeof(ctrl_full_name), "%s_%s",
+ f->name, resctrl_ctrl_name_str(emul->name));
+
+ kn_emul = kernfs_create_dir(kn_ctrl, ctrl_full_name,
+ kn_ctrl->mode, emul);
+ if (IS_ERR(kn_emul))
+ return PTR_ERR(kn_emul);
+
+ ret = rdtgroup_kn_set_ugid(kn_emul);
+ if (ret)
+ return ret;
+
+ ret = resctrl_add_ctrl_files(kn_emul, emul);
+ if (ret)
+ return ret;
+ }
+ } else {
+ ret = resctrl_add_ctrl_files(kn_ctrl, ctrl);
+ if (ret)
+ return ret;
+ }
}

kernfs_activate(kn_subdir);
--
2.43.0