Re: [PATCH v5 27/29] fs/resctrl: Add file system mechanism for architecture info file
From: Luck, Tony
Date: Fri Jun 06 2025 - 13:31:36 EST
On Fri, Jun 06, 2025 at 09:26:06AM -0700, Reinette Chatre wrote:
> With /sys/kernel/debug/resctrl potentially mirroring /sys/fs/resctrl to
> support various debugging scenarios there may later be resource level
> debugging for which a "/sys/kernel/debug/resctrl/info/<resource>/<debugfile>" can
> be used. Considering this it looks to me as though one possible boundary could
> be to isolate arch specific debug to, for example, a new directory named
> "/sys/kernel/debug/resctrl/info/arch_debug_name_tbd/". By placing the
> arch debug in a sub-directory named "info" it avoids collision with resource
> group names with naming that also avoids collision with resource names since
> all these names are controlled by resctrl fs.
That seems like a good path. PoC patch below. Note that I put the dentry
for the debug info directory into struct rdt_resource. So no call from
architecture to file system code needed to access.
Directory layout looks like this:
# tree /sys/kernel/debug/resctrl/
/sys/kernel/debug/resctrl/
└── info
├── L2
├── L3
├── MB
└── SMBA
6 directories, 0 files
-Tony
---
diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index 5e28e81b35f6..78dd0f8f7ad8 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -281,6 +281,7 @@ enum resctrl_schema_fmt {
* @mbm_cfg_mask: Bandwidth sources that can be tracked when bandwidth
* monitoring events can be configured.
* @cdp_capable: Is the CDP feature available on this resource
+ * @arch_debug_info: Debugfs info directory for architecture use
*/
struct rdt_resource {
int rid;
@@ -297,6 +298,7 @@ struct rdt_resource {
enum resctrl_schema_fmt schema_fmt;
unsigned int mbm_cfg_mask;
bool cdp_capable;
+ struct dentry *arch_debug_info;
};
/*
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index ed4fc45da346..48c587201fb6 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -4274,6 +4274,8 @@ void resctrl_offline_cpu(unsigned int cpu)
*/
int resctrl_init(void)
{
+ struct dentry *debuginfodir;
+ struct rdt_resource *r;
int ret = 0;
seq_buf_init(&last_cmd_status, last_cmd_status_buf,
@@ -4320,6 +4322,12 @@ int resctrl_init(void)
*/
debugfs_resctrl = debugfs_create_dir("resctrl", NULL);
+ /* Create debug info directories for each resource */
+ debuginfodir = debugfs_create_dir("info", debugfs_resctrl);
+
+ for_each_rdt_resource(r)
+ r->arch_debug_info = debugfs_create_dir(r->name, debuginfodir);
+
return 0;
cleanup_mountpoint: