Re: [PATCH v7 11/14] mpam,x86/resctrl: Resolve INTEL_PMT_TELEMETRY symbols at runtime
From: Luck, Tony
Date: Thu Jun 11 2026 - 18:27:35 EST
On Thu, Jun 11, 2026 at 02:22:23PM -0700, Reinette Chatre wrote:
> Hi Tony,
>
> On 6/11/26 11:01 AM, Luck, Tony wrote:
> > With renamed variable, and comment. Is this clearer?
> >
> >
> > /*
> > * intel_aet_register_enumeration() provides the value of "THIS_MODULE"
> > * from the the pmt_telemetry module. Note that this is NULL when
> > * CONFIG_INTEL_PMT_TELEMETRY=y so it serves as a flag to decide whether
> > * try_module_get() and module_put() need to be called.
> > */
> > static struct module *pmt_is_a_module;
> >
>
> Using a single variable to contain both data and state has caused problem in
> the past. Could it be helpful to create two utilities, for example get_pmt()
> and put_pmt() although naming is not at issue at the moment, that contains
> and makes obvious these "is INTEL_PMT_TELEMETRY a module or not" checks? These would
> then be no-op when INTEL_PMT_TELEMETRY=y. This would simplify the code in the
> callers by containing this logic and not rely on callers doing this check so
> many times.
I can code this up to see how it looks.
> Even so, it is not clear to me how the AET lifetime will look like since
> INTEL_PMT_TELEMETRY's .remove() may be called at other times so resctrl
> may need other hooks that could replace this module handling.
Case 1: No races
Resctrl mount: intel_aet_pre_mount() gets a success return from
try_module_get() - so the hold on the pmt_module will block the
kernel from removing the module (-EBUSY).
Case 2: Race between resctrl mount and rmmod pmt_telemetry
Mount code gets into intel_aet_pre_mount() and rmmod gets to intel_aet_unregister_enumeration()
where both try to acquire aet_register_lock.
If intel_aet_pre_mount() gets the mutex it calls try_module_get(), which
fails because if the pmt_telemetry code is in the .remove() functions,
then the module state is already in MODULE_STATE_GOING.
If rmmod process wins the mutex it sets get_feature and put_feature to
NULL and releases the mutex. intel_aet_pre_mount() runs and returns
false because get_feature and put_feature are NULL.
Is there some other race condition to consider?
> Reinette
-Tony
P.S. David Box is OK with setting suppress_bind_attrs for the telemetry
driver. So that will make the unbind issue moot.
>