[PATCH v6 10/18] fs/resctrl: Add support for hidden resource group files

From: Babu Moger

Date: Thu Oct 01 2026 - 11:33:28 EST


Some per-group resctrl files are only meaningful once a resource group
has an active kernel mode association.

Creating them only at activation would complicate group setup and
teardown, while exposing them on every group would show empty files
with no clear purpose.

Add a hidden property to struct rftype to hide files at creation.

Suggested-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v6: Removed resctrl_hidden_files_set_visible() from the patch.
It will be separate patch.
Re-wrote the changelog.

v5: New patch to add support for creating hidden files.
---
fs/resctrl/internal.h | 2 ++
fs/resctrl/rdtgroup.c | 3 +++
2 files changed, 5 insertions(+)

diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 98f04a2a762b..986b9c942fb2 100644
--- a/fs/resctrl/internal.h
+++ b/fs/resctrl/internal.h
@@ -283,6 +283,7 @@ extern int max_name_width;
* @kf_ops: File operations
* @flags: File specific RFTYPE_FLAGS_* flags
* @fflags: File specific RFTYPE_* flags
+ * @hidden: Hide file at creation; visibility may be restored later
* @seq_show: Show content of the file
* @write: Write to the file
*/
@@ -292,6 +293,7 @@ struct rftype {
const struct kernfs_ops *kf_ops;
unsigned long flags;
unsigned long fflags;
+ bool hidden;

int (*seq_show)(struct kernfs_open_file *of,
struct seq_file *sf, void *v);
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index e82709d64a00..46b2cafd9411 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -308,6 +308,9 @@ static int rdtgroup_add_file(struct kernfs_node *parent_kn, struct rftype *rft)
return ret;
}

+ if (rft->hidden)
+ kernfs_show(kn, false);
+
return 0;
}

--
2.43.0