Re: [PATCH v10 11/17] arm,x86/resctrl: Resolve INTEL_PMT_TELEMETRY symbols at runtime
Reinette Chatre <[email protected]>
| Newsgroups | dev.linux.lists.patches,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
Hi Tony, On 7/29/26 10:27 AM, Tony Luck wrote: > resctrl is always built-in, but INTEL_PMT_TELEMETRY and INTEL_TPMI are > logically independent and should be loadable modules. Switch AET to use the > function-pointer registration API instead of direct link-time references to > PMT symbols. > > Prepare for the file system to call resctrl_arch_pre_mount() on every mount > by moving AET enumeration into resctrl_arch_pre_mount() and cleanup into > resctrl_arch_unmount(). This allows the PMT module to be unloaded whenever > the filesystem is not mounted. > > intel_aet_exit() was never called because resctrl is built into the kernel. All > cleanup is now handled in the unmount path. Remove intel_aet_exit(). > > Note that the Linux file system code does not serialize calls to > fs_context_operations::get_tree(), so there may be arbitrarily many parallel > calls if users invoke mount(2) multiple times. > > Zero rdt_resource::resctrl_mon::num_rmid for RDT_RESOURCE_PERF_PKG so > that it will be re-computed next mount. > > event_group::num_rmid may be reset (reduced) during enumeration. This is > not worth resetting on unmount because the same reduction would occur on > each subsequent mount. I think it will be helpful to reviewers (including sashiko) to add description why the unbalanced module reference counting is safe here. > > Signed-off-by: Tony Luck <[email protected]> > --- ... > diff --git a/arch/x86/kernel/cpu/resctrl/core.c b/arch/x86/kernel/cpu/resctrl/core.c > index 2c938b97b147..e335a143f3e5 100644 > --- a/arch/x86/kernel/cpu/resctrl/core.c > +++ b/arch/x86/kernel/cpu/resctrl/core.c > @@ -16,10 +16,12 @@ > > #define pr_fmt(fmt) "resctrl: " fmt > > +#include <linux/cleanup.h> Following patch removing this could just be squashed here? > #include <linux/cpu.h> > #include <linux/slab.h> > #include <linux/err.h> > #include <linux/cpuhotplug.h> > +#include <linux/mutex.h> > > #include <asm/cpu_device_id.h> > #include <asm/cpuid/api.h> ... > diff --git a/arch/x86/kernel/cpu/resctrl/intel_aet.c b/arch/x86/kernel/cpu/resctrl/intel_aet.c > index 407c9aba5eea..65b70cc8d0a5 100644 > --- a/arch/x86/kernel/cpu/resctrl/intel_aet.c > +++ b/arch/x86/kernel/cpu/resctrl/intel_aet.c ... > @@ -340,10 +342,22 @@ void __init intel_aet_init(void) > (*peg)->num_rmid = min(max_rmid, (*peg)->num_rmid); > } > > +/* > + * Defend against races between module load/unload of the pmt_telemetry > + * module and mount/unmount of the resctrl file system. Please add to this comment what data is protected by this mutex. > + */ > +static DEFINE_MUTEX(aet_register_lock); > + > +/* > + * Track whether pmt_telemetry enumeration succeeded during mount for use during unmount. > + */ > +static bool pmt_in_use; Reinette