[PATCH v7 11/19] fs/resctrl: Add support for hidden resource group files

From: Babu Moger

Date: Wed Nov 11 2026 - 18:06:49 EST


A resctrl file is visible to user space as soon as its resource group
directory is activated. A file can only be hidden after it has been
created, as is done for the info directory's BMEC event configuration
files.

In the global_enable_per_cpu kernel mode, kernel work running on CPUs where
the mode is active uses the CLOSID and/or RMID as part of a single backing
resource group. The files needed to display and modify the CPUs on which
this kernel mode is active are only meaningful in that group. Visible in
every resource group, the files would return errors when accessed in any
group other than the one backing the active kernel mode. Creating the files
when the kernel mode is activated, and removing them when it is
deactivated, would add failure paths to kernel mode activation that showing
and hiding existing files does not have.

Allow a resource group file to be marked as hidden so that it is hidden
when created, before its directory is activated, and is never visible to
user space until resctrl restores its visibility. This provides the
foundation in preparation for kernel mode support that shows the kmode_cpus
and kmode_cpus_list files only in the resource group backing the active
kernel mode.

Suggested-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v7: Updated the changelog (Reinette's input with minor update in second
paragrapj).

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 38aa0c0cfb7e..909511e985a1 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 afbe0f94940a..9235f094245c 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -313,6 +313,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