[PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area

Tony Luck posted 32 patches 1 month, 3 weeks ago
There is a newer version of this series
[PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area
Posted by Tony Luck 1 month, 3 weeks ago
All files below /sys/fs/resctrl are considered user ABI.

This leaves no place for architectures to provide additional interfaces.

Add resctrl_debugfs_mon_info_arch_mkdir() which creates a directory in
the debugfs file system for a monitoring resource. Naming follows the
layout of the main resctrl hierarchy:

	/sys/kernel/debug/resctrl/info/{resource}_MON/{arch}

The {arch} last level directory name matches the output of the user level
"uname -m" command.

Architecture code may use this directory for debug information, or for minor
tuning of features. It must not be used for basic feature enabling as debugfs
may not be configured/mounted on production systems.

Suggested-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Tony Luck <tony.luck@intel.com>
Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>
---
 include/linux/resctrl.h | 10 ++++++++++
 fs/resctrl/rdtgroup.c   | 29 +++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+)

diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 8623e450619a..b862a9dd785b 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -702,6 +702,16 @@ bool resctrl_arch_get_io_alloc_enabled(struct rdt_resource *r);
 extern unsigned int resctrl_rmid_realloc_threshold;
 extern unsigned int resctrl_rmid_realloc_limit;
 
+/**
+ * resctrl_debugfs_mon_info_arch_mkdir() - Create a debugfs info directory.
+ *					   Removed by resctrl_exit().
+ * @r:	Resource (must be mon_capable).
+ *
+ * Return: NULL if resource is not monitoring capable,
+ * dentry pointer on success, or ERR_PTR(-ERROR) on failure.
+ */
+struct dentry *resctrl_debugfs_mon_info_arch_mkdir(struct rdt_resource *r);
+
 int resctrl_init(void);
 void resctrl_exit(void);
 
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index d49ffc56ea61..d13291d71adf 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -24,6 +24,7 @@
 #include <linux/sched/task.h>
 #include <linux/slab.h>
 #include <linux/user_namespace.h>
+#include <linux/utsname.h>
 
 #include <uapi/linux/magic.h>
 
@@ -75,6 +76,8 @@ static void rdtgroup_destroy_root(void);
 
 struct dentry *debugfs_resctrl;
 
+static struct dentry *debugfs_resctrl_info;
+
 /*
  * 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
@@ -4599,6 +4602,31 @@ int resctrl_init(void)
 	return ret;
 }
 
+/*
+ * Create /sys/kernel/debug/resctrl/info/{r->name}_MON/{arch} directory
+ * by request for architecture to use for debugging or minor tuning.
+ * Basic functionality of features must not be controlled by files
+ * added to this directory as debugfs may not be configured/mounted
+ * on production systems.
+ */
+struct dentry *resctrl_debugfs_mon_info_arch_mkdir(struct rdt_resource *r)
+{
+	struct dentry *moninfodir;
+	char name[32];
+
+	if (!r->mon_capable)
+		return NULL;
+
+	if (!debugfs_resctrl_info)
+		debugfs_resctrl_info = debugfs_create_dir("info", debugfs_resctrl);
+
+	sprintf(name, "%s_MON", r->name);
+
+	moninfodir = debugfs_create_dir(name, debugfs_resctrl_info);
+
+	return debugfs_create_dir(utsname()->machine, moninfodir);
+}
+
 static bool resctrl_online_domains_exist(void)
 {
 	struct rdt_resource *r;
@@ -4650,6 +4678,7 @@ void resctrl_exit(void)
 
 	debugfs_remove_recursive(debugfs_resctrl);
 	debugfs_resctrl = NULL;
+	debugfs_resctrl_info = NULL;
 	unregister_filesystem(&rdt_fs_type);
 
 	/*
-- 
2.52.0
Re: [PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area
Posted by Borislav Petkov 3 weeks, 6 days ago
On Wed, Dec 17, 2025 at 09:21:17AM -0800, Tony Luck wrote:
> All files below /sys/fs/resctrl are considered user ABI.
> 
> This leaves no place for architectures to provide additional interfaces.
> 
> Add resctrl_debugfs_mon_info_arch_mkdir() which creates a directory in
> the debugfs file system for a monitoring resource. Naming follows the
> layout of the main resctrl hierarchy:
> 
> 	/sys/kernel/debug/resctrl/info/{resource}_MON/{arch}
> 
> The {arch} last level directory name matches the output of the user level
> "uname -m" command.
> 
> Architecture code may use this directory for debug information, or for minor
> tuning of features. It must not be used for basic feature enabling as debugfs
> may not be configured/mounted on production systems.

I, like you guys, thought that debugfs is "safe" in the sense, stuff there
can't really be an ABI but just recently at LPC I got schooled about it and,
basically, if anything in luserspace starts using debugfs, it will be
considered an ABI.

And this thinking has been there for a looong time now:

https://lwn.net/Articles/309298/

So, before you put anything there, think again because you might end up
supporting it just like an ABI.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
Re: [PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area
Posted by Luck, Tony 3 weeks, 6 days ago
On Sat, Jan 10, 2026 at 11:57:58AM +0100, Borislav Petkov wrote:
> On Wed, Dec 17, 2025 at 09:21:17AM -0800, Tony Luck wrote:
> > All files below /sys/fs/resctrl are considered user ABI.
> > 
> > This leaves no place for architectures to provide additional interfaces.
> > 
> > Add resctrl_debugfs_mon_info_arch_mkdir() which creates a directory in
> > the debugfs file system for a monitoring resource. Naming follows the
> > layout of the main resctrl hierarchy:
> > 
> > 	/sys/kernel/debug/resctrl/info/{resource}_MON/{arch}
> > 
> > The {arch} last level directory name matches the output of the user level
> > "uname -m" command.
> > 
> > Architecture code may use this directory for debug information, or for minor
> > tuning of features. It must not be used for basic feature enabling as debugfs
> > may not be configured/mounted on production systems.
> 
> I, like you guys, thought that debugfs is "safe" in the sense, stuff there
> can't really be an ABI but just recently at LPC I got schooled about it and,
> basically, if anything in luserspace starts using debugfs, it will be
> considered an ABI.
> 
> And this thinking has been there for a looong time now:
> 
> https://lwn.net/Articles/309298/
> 
> So, before you put anything there, think again because you might end up
> supporting it just like an ABI.

Please drop patches 30, 31, and the debugfs hunk to Documentation from patch 32
while I look at options. The debugfs bits aren't needed for normal
operation, just for debugging if things don't appear to be working as
expected. No need to hold up inclusion waiting for a solution.

Telemetry based events tied to RMIDs are new in Clearwater Forest. I
have line of sight to a second platorm. But extrapolating from two
data points to decide on a stable ABI seems very risky.

Thanks

-Tony
Re: [PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area
Posted by Borislav Petkov 3 weeks, 6 days ago
On Sat, Jan 10, 2026 at 11:13:40AM -0800, Luck, Tony wrote:
> Please drop patches 30, 31, and the debugfs hunk to Documentation from patch 32
> while I look at options. The debugfs bits aren't needed for normal
> operation, just for debugging if things don't appear to be working as
> expected. No need to hold up inclusion waiting for a solution.
> 
> Telemetry based events tied to RMIDs are new in Clearwater Forest. I
> have line of sight to a second platorm. But extrapolating from two
> data points to decide on a stable ABI seems very risky.

Ok, makes sense.

I've pushed out the branch, you could have a look and lemme know whether
something's still amiss.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette
RE: [PATCH v17 30/32] fs/resctrl: Provide interface to create architecture specific debugfs area
Posted by Luck, Tony 3 weeks, 6 days ago
> I've pushed out the branch, you could have a look and lemme know whether
> something's still amiss.

Basic build and simple tests pass. So looks good so far.

Thanks

-Tony