[PATCH 13/32] x86,fs/resctrl: Add an architectural hook called for first mount

Tony Luck posted 3 patches 4 weeks, 1 day ago
[PATCH 13/32] x86,fs/resctrl: Add an architectural hook called for first mount
Posted by Tony Luck 4 weeks, 1 day ago
Enumeration of Intel telemetry events is an asynchronous process involving
several mutually dependent drivers added as auxiliary devices during
the device_initcall() phase of Linux boot. The process finishes after
the probe functions of these drivers completes. But this happens after
resctrl_arch_late_init() is executed.

Tracing the enumeration process shows that it does complete a full seven
seconds before the earliest possible mount of the resctrl file system (when
included in /etc/fstab for automatic mount by systemd).

Add a hook at the beginning of the mount code that will be used to check
for telemetry events and initialize if any are found.

The hook is only called on the first mount of the resctrl file system as
that is all that is needed for telemetry enumeration.

resctrl filesystem calls the hook with no locks held. Architecture code is
responsible for any required locking.

Signed-off-by: Tony Luck <tony.luck@intel.com>
---
 include/linux/resctrl.h            | 6 ++++++
 arch/x86/kernel/cpu/resctrl/core.c | 4 ++++
 fs/resctrl/rdtgroup.c              | 3 +++
 3 files changed, 13 insertions(+)

diff --git a/include/linux/resctrl.h b/include/linux/resctrl.h
index c43526cdf304..2f938a5a16f8 100644
--- a/include/linux/resctrl.h
+++ b/include/linux/resctrl.h
@@ -514,6 +514,12 @@ void resctrl_offline_mon_domain(struct rdt_resource *r, struct rdt_domain_hdr *h
 void resctrl_online_cpu(unsigned int cpu);
 void resctrl_offline_cpu(unsigned int cpu);
 
+/*
+ * Architecture hook called at beginning of first file system mount attempt.
+ * No locks are held.
+ */
+void resctrl_arch_pre_mount(void);
+
 /**
  * resctrl_arch_rmid_read() - Read the eventid counter corresponding to rmid
  *			      for this resource and domain.
diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c
index 9222eee7ce07..a2b7f869b4b0 100644
--- a/arch/x86/kernel/cpu/resctrl/core.c
+++ b/arch/x86/kernel/cpu/resctrl/core.c
@@ -726,6 +726,10 @@ static int resctrl_arch_offline_cpu(unsigned int cpu)
 	return 0;
 }
 
+void resctrl_arch_pre_mount(void)
+{
+}
+
 enum {
 	RDT_FLAG_CMT,
 	RDT_FLAG_MBM_TOTAL,
diff --git a/fs/resctrl/rdtgroup.c b/fs/resctrl/rdtgroup.c
index 771e40f02ba6..0e3b8bcf4e53 100644
--- a/fs/resctrl/rdtgroup.c
+++ b/fs/resctrl/rdtgroup.c
@@ -18,6 +18,7 @@
 #include <linux/fs_parser.h>
 #include <linux/sysfs.h>
 #include <linux/kernfs.h>
+#include <linux/once.h>
 #include <linux/resctrl.h>
 #include <linux/seq_buf.h>
 #include <linux/seq_file.h>
@@ -2785,6 +2786,8 @@ static int rdt_get_tree(struct fs_context *fc)
 	struct rdt_resource *r;
 	int ret;
 
+	DO_ONCE_SLEEPABLE(resctrl_arch_pre_mount);
+
 	cpus_read_lock();
 	mutex_lock(&rdtgroup_mutex);
 	/*
-- 
2.52.0
Re: [PATCH 13/32] x86,fs/resctrl: Add an architectural hook called for first mount
Posted by Reinette Chatre 4 weeks ago
Hi Tony,

On 1/8/26 9:42 AM, Tony Luck wrote:
> Enumeration of Intel telemetry events is an asynchronous process involving
> several mutually dependent drivers added as auxiliary devices during
> the device_initcall() phase of Linux boot. The process finishes after
> the probe functions of these drivers completes. But this happens after
> resctrl_arch_late_init() is executed.
> 
> Tracing the enumeration process shows that it does complete a full seven
> seconds before the earliest possible mount of the resctrl file system (when
> included in /etc/fstab for automatic mount by systemd).
> 
> Add a hook at the beginning of the mount code that will be used to check
> for telemetry events and initialize if any are found.
> 
> The hook is only called on the first mount of the resctrl file system as
> that is all that is needed for telemetry enumeration.

Needs imperative. "Only call the hook on the first mount ..."?
Although, to help with brevity, the last three sentences could be merged. For example:

	Add a hook for use by telemetry event enumeration and initialization and
	run it once at the beginning of resctrl mount without any locks held.
	Architecture is responsible for any required locking.

> 
> resctrl filesystem calls the hook with no locks held. Architecture code is
> responsible for any required locking.
> 
> Signed-off-by: Tony Luck <tony.luck@intel.com>
> ---

| Reviewed-by: Reinette Chatre <reinette.chatre@intel.com>

Reinette
Re: [PATCH 13/32] x86,fs/resctrl: Add an architectural hook called for first mount
Posted by Borislav Petkov 4 weeks ago
On Fri, Jan 09, 2026 at 07:28:25AM -0800, Reinette Chatre wrote:
> Needs imperative. "Only call the hook on the first mount ..."?
> Although, to help with brevity, the last three sentences could be merged. For example:
> 
> 	Add a hook for use by telemetry event enumeration and initialization and
> 	run it once at the beginning of resctrl mount without any locks held.
> 	Architecture is responsible for any required locking.

Done.

Thx.

-- 
Regards/Gruss,
    Boris.

https://people.kernel.org/tglx/notes-about-netiquette