Re: [patch V3 01/40] cpu/SMT: Make SMT control more robust against enumeration failures

From: Borislav Petkov
Date: Fri Aug 04 2023 - 13:51:27 EST


On Wed, Aug 02, 2023 at 12:20:59PM +0200, Thomas Gleixner wrote:
> kernel/cpu.c | 6 ++++++
> 1 file changed, 6 insertions(+)
> --- a/kernel/cpu.c
> +++ b/kernel/cpu.c
> @@ -630,6 +630,12 @@ static inline bool cpu_smt_allowed(unsig

As discussed on IRC, the name and what the function does is kinda
conflicting.

What it actually queries is whether the CPU can be booted. So something
like this ontop I guess:

---
diff --git a/kernel/cpu.c b/kernel/cpu.c
index f93ce69f7e3d..e4195d5425cb 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -659,7 +659,7 @@ static inline bool cpu_smt_thread_allowed(unsigned int cpu)
#endif
}

-static inline bool cpu_smt_allowed(unsigned int cpu)
+static inline bool cpu_bootable(unsigned int cpu)
{
if (cpu_smt_control == CPU_SMT_ENABLED && cpu_smt_thread_allowed(cpu))
return true;
@@ -691,7 +691,7 @@ bool cpu_smt_possible(void)
EXPORT_SYMBOL_GPL(cpu_smt_possible);

#else
-static inline bool cpu_smt_allowed(unsigned int cpu) { return true; }
+static inline bool cpu_bootable(unsigned int cpu) { return true; }
#endif

static inline enum cpuhp_state
@@ -794,10 +794,10 @@ static int bringup_wait_for_ap_online(unsigned int cpu)
* SMT soft disabling on X86 requires to bring the CPU out of the
* BIOS 'wait for SIPI' state in order to set the CR4.MCE bit. The
* CPU marked itself as booted_once in notify_cpu_starting() so the
- * cpu_smt_allowed() check will now return false if this is not the
+ * cpu_bootable() check will now return false if this is not the
* primary sibling.
*/
- if (!cpu_smt_allowed(cpu))
+ if (!cpu_bootable(cpu))
return -ECANCELED;
return 0;
}
@@ -1725,7 +1725,7 @@ static int cpu_up(unsigned int cpu, enum cpuhp_state target)
err = -EBUSY;
goto out;
}
- if (!cpu_smt_allowed(cpu)) {
+ if (!cpu_bootable(cpu)) {
err = -EPERM;
goto out;
}

--
Regards/Gruss,
Boris.

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