[PATCH v7 13/19] x86,fs/resctrl: Add CPU hotplug support for kernel mode

Reinette Chatre reinette.chatre at intel.com
Tue Dec 1 21:02:42 PST 2026


Hi Babu,

On 11/16/26 12:08 PM, Babu Moger wrote:
> On 11/11/26 16:44, Babu Moger wrote:
... 
>> diff --git a/arch/x86/kernel/cpu/resctrl/core.c 
> b/arch/x86/kernel/cpu/resctrl/core.c
>> index fc59d66f77de1..33965b760aed0 100644
>> --- a/arch/x86/kernel/cpu/resctrl/core.c
>> +++ b/arch/x86/kernel/cpu/resctrl/core.c
>> @@ -735,6 +735,9 @@ static void clear_closid_rmid(int cpu)
>>      state->cur_closid = RESCTRL_RESERVED_CLOSID;
>>      state->cur_rmid = RESCTRL_RESERVED_RMID;
>>      wrmsrq(MSR_IA32_PQR_ASSOC, val.q);
>> +
>> +    if (boot_cpu_has(X86_FEATURE_PLZA))
>> +        wrmsrq(MSR_IA32_PQR_PLZA_ASSOC, 0);
>>  }
> 
> Does zeroing MSR_IA32_PQR_PLZA_ASSOC in clear_closid_rmid() clobber the
> domain's active PLZA configuration during CPU hotplug?
> 
> When a CPU goes offline while RESCTRL_GLOBAL_ENABLE_PER_CPU is active,
> resctrl_arch_offline_cpu() first runs resctrl_offline_cpu() ->
> resctrl_kmode_global_offline_cpu(), which clears plza_en while preserving rmid, rmid_en, closid, and closid_en in MSR_IA32_PQR_PLZA_ASSOC (or leaves the MSR untouched if the CPU was not in kmode_cpu_mask). Immediately afterward, resctrl_arch_offline_cpu() calls clear_closid_rmid() and writes 0 to MSR_IA32_PQR_PLZA_ASSOC:
> 
> arch/x86/kernel/cpu/resctrl/core.c:resctrl_arch_offline_cpu() {
>     ...
>     resctrl_offline_cpu(cpu);
> 
>     mutex_lock(&domain_list_lock);
>     for_each_capable_rdt_resource(r)
>         domain_remove_cpu(cpu, r);
>     mutex_unlock(&domain_list_lock);
> 
>     clear_closid_rmid(cpu);
>     ...
> }
> 
> That overwrites the MSR value just programmed by
> resctrl_kmode_global_offline_cpu() and zeroes rmid, rmid_en, closid, and
> closid_en on the offlined CPU while other CPUs in the same QoS domain
> still have the active kernel mode configuration programmed, violating the hardware requirement documented for union msr_pqr_plza_assoc that all fields except plza_en must 

I do not believe any implementation can ensure that offline CPUs have the same
configuration as online CPUs. 

be programmed identically across every CPU in a QoS domain. During CPU online, resctrl_arch_online_cpu() likewise calls clear_closid_rmid() after domain_add_cpu() and before resctrl_online_cpu() takes rdtgroup_mutex to program the active configuration.
> =======================================================================
> 
> Yes. This is an issue. We cannot write 0 to MSR_IA32_PQR_PLZA_ASSOC in hotplug handler.
> 
> Couple of options:
> 
> 1. Introduce the reboot notifier for resctrl and clear MSR_IA32_PQR_PLZA_ASSOC. Reboot notifier is called during kexec reboot.

Shouldn't new kernel anyway run all the CPU online handlers that should reconfigure the
kernel mode?

> 
> or
> 
> 2. Just clear the PLZA_EN bit in clear_closid_rmid().
>    if (boot_cpu_has(X86_FEATURE_PLZA))
>        msr_clear_bit(MSR_IA32_PQR_PLZA_ASSOC, PLZA_EN);

This still leaves all the old fields in place, no?

I am considering the following scenario: 
- User activates global_enable_per_cpu with group A and then switches to inherit_user.
- Every online CPU still holds A's CLOSID/RMID in PLZA_ASSOC (plza_en = 0).
- Nothing records that system is still configured with A's properties.
- A CPU that comes online later gets 0 from clear_closid_rmid(), and resctrl_kmode_global_online_cpu()
  returns early because the mode is inactive. That CPU now differs from all the others, permanently.
- A can later be removed and its CLOSID/RMID reused, while the PLZA_ASSOC still hold them.

I think a problem is that rdtgroup_kmode_global_deactivate() deactivates the kernel mode
using the now-unused resource group's properties as values and then restores the driver
state to defaults. After this, what is programmed on hardware and what is stored in resctrl
disagrees.

I believe the rule should be "every online CPU holds the current configuration, and only plza_en
differs per CPU". To accomplish this I think the deactivate path needs to change to reset
to defaults and to program the defaults to *all* online CPUs, not just those associated with 
the kernel mode. To accomplish this I think there is a need for a new "reset" helper that
can be done without a new arch helper and can look something like:


	static void resctrl_reset_kmode_global(const struct cpumask *mask)                                                   
	{
		resctrl_arch_configure_kmode_global(mask, RESCTRL_RESERVED_CLOSID, false,                                    
                				    RESCTRL_RESERVED_RMID, false, false);
	}

Above helper can be called on all online CPUs when kernel mode is deactivated, and per-CPU
on the CPU going offline.

The kexec scenarios are not quite clear to me and it will be helpful if the changelog
can elaborate what is required here. If, for example, a PLZA enabled kernel boots first
and is used, follows by a PLZA disabled kernel, the second kernel will not set
RESCTRL_GLOBAL_ENABLE_PER_CPU. In this case there may be a need for the arch driver to
do some reset, which is why I *guess* this patch uses boot_cpu_has(). If this is the
case there really needs to be more descriptions and comments to explain, perhaps even as
a separate commit?

Reinette



More information about the linux-arm-kernel mailing list