Re: [PATCH v6 1/4] x86/smp: Allow calling mwait_play_dead with an arbitrary hint

From: Patryk Wlazlyn
Date: Fri Nov 29 2024 - 07:09:57 EST


>> The MWAIT instruction needs different hints on different CPUs to reach
>> specific idle states. The current hint calculation in mwait_play_dead()
>> code works in practice on current Intel hardware, but is not documented
>> and fails on a recent Intel's Sierra Forest and possibly some future
>> ones. Those newer CPUs' power efficiency suffers when the CPU is put
>> offline.
>>
>> Allow cpuidle code to provide mwait_play_dead with a known hint for
>> efficient play_dead code.
>
>
> Just a couple of minor nits:
>
> You could just reword this something along the lines of:
>
> "Introduce a helper function to allow offlined CPUs to enter FFh idle
> states with a specific MWAIT hint. The new helper will be used in
> subsequent patches by the acpi_idle and intel_idle drivers. This patch
> should not have any functional impact."
>
> There is no need to mention MWAIT hint calculation and the Sierra
> Forest failure in this patch, as this patch is not doing anything to
> fix the issue. Very likely you will be covering that in Patch 4.

Ok. I thought that giving some context on how the change originated might be
useful, but people doesn't seem to like that that much ;]

> "(...) This patch should not have any functional impact."

Yeah, forgot to put that no functional change intended.

>>
>> Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@xxxxxxxxxxxxxxx>
>> ---
>>  arch/x86/include/asm/smp.h |  4 +-
>>  arch/x86/kernel/smpboot.c  | 86 ++++++++++++++++++++------------------
>>  2 files changed, 49 insertions(+), 41 deletions(-)
>>
>> diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
>> index ca073f40698f..ab90b95037f3 100644
>> --- a/arch/x86/include/asm/smp.h
>> +++ b/arch/x86/include/asm/smp.h
>> @@ -114,6 +114,7 @@ void wbinvd_on_cpu(int cpu);
>>  int wbinvd_on_all_cpus(void);
>>  
>>  void smp_kick_mwait_play_dead(void);
>> +void mwait_play_dead_with_hint(unsigned int hint);

That actually is needed.

>>  
>>  void native_smp_send_reschedule(int cpu);
>>  void native_send_call_func_ipi(const struct cpumask *mask);
>> @@ -151,7 +152,6 @@ static inline struct cpumask *cpu_l2c_shared_mask(int cpu)
>>  {
>>      return per_cpu(cpu_l2c_shared_map, cpu);
>>  }
>> -

Yeah, missed that one when submitting.

>>  #else /* !CONFIG_SMP */
>>  #define wbinvd_on_cpu(cpu)     wbinvd()
>>  static inline int wbinvd_on_all_cpus(void)
>
> This hunk is not relevant to this patch.