[PATCH v5 10/16] fs/resctrl: Add support for hidden resource group files
From: Babu Moger
Date: Wed Aug 26 2026 - 15:36:59 EST
Some per-group resctrl files are only meaningful once a resource group
has an active kernel mode association (for example, kmode_cpus on the
associated group).
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, and
resctrl_hidden_files_set_visible() to show or hide them when association
state changes.
Suggested-by: Reinette Chatre <reinette.chatre@xxxxxxxxx>
Signed-off-by: Babu Moger <babu.moger@xxxxxxx>
---
v5: New patch to add support for creating hidden files.
---
fs/resctrl/internal.h | 4 ++++
fs/resctrl/rdtgroup.c | 30 ++++++++++++++++++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/fs/resctrl/internal.h b/fs/resctrl/internal.h
index 4087bf44a06d..b56f95625072 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);
@@ -480,6 +482,8 @@ ssize_t resctrl_mbm_assign_mode_write(struct kernfs_open_file *of, char *buf,
void resctrl_bmec_files_show(struct rdt_resource *r, struct kernfs_node *l3_mon_kn,
bool show);
+void resctrl_hidden_files_set_visible(struct kernfs_node *kn, bool show);
+
int resctrl_num_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s, void *v);
int resctrl_available_mbm_cntrs_show(struct kernfs_open_file *of, struct seq_file *s,
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 992af586a194..d2fff8adf915 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -312,6 +312,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;
}
@@ -2377,6 +2380,33 @@ static int rdtgroup_add_files(struct kernfs_node *kn, unsigned long fflags)
return ret;
}
+/*
+ * resctrl_hidden_files_set_visible() - Show or hide files marked hidden
+ * @kn: resource group kernfs_node
+ * @show: whether to show or hide
+ *
+ * Iterate res_common_files entries marked hidden and show or hide the
+ * corresponding file under @kn.
+ */
+void resctrl_hidden_files_set_visible(struct kernfs_node *kn, bool show)
+{
+ struct rftype *rft, *rfts = res_common_files;
+ struct kernfs_node *kn_file;
+ int len;
+
+ len = ARRAY_SIZE(res_common_files);
+ for (rft = rfts; rft < rfts + len; rft++) {
+ if (!rft->hidden)
+ continue;
+
+ kn_file = kernfs_find_and_get(kn, rft->name);
+ if (!kn_file)
+ continue;
+ kernfs_show(kn_file, show);
+ kernfs_put(kn_file);
+ }
+}
+
static struct rftype *rdtgroup_get_rftype_by_name(const char *name)
{
struct rftype *rfts, *rft;
--
2.43.0