x86/cpu/topology: Simplify cpu_mark_primary_thread()
authorThomas Gleixner <tglx@linutronix.de>
Tue, 13 Feb 2024 21:06:06 +0000 (22:06 +0100)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 15 Feb 2024 21:07:44 +0000 (22:07 +0100)
No point in creating a mask via fls(). smp_num_siblings is guaranteed to be
a power of 2. So just using (smp_num_siblings - 1) has the same effect.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Michael Kelley <mhklinux@outlook.com>
Tested-by: Sohil Mehta <sohil.mehta@intel.com>
Link: https://lore.kernel.org/r/20240213210252.791176581@linutronix.de
arch/x86/kernel/cpu/topology.c

index f3397e233ffbdb7f59060b281d93268201c836ab..aea408de3be44ea42cb2ab89bd7fb0c9d65848c1 100644 (file)
@@ -76,10 +76,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
 #ifdef CONFIG_SMP
 static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid)
 {
-       /* Isolate the SMT bit(s) in the APICID and check for 0 */
-       u32 mask = (1U << (fls(smp_num_siblings) - 1)) - 1;
-
-       if (smp_num_siblings == 1 || !(apicid & mask))
+       if (!(apicid & (smp_num_siblings - 1)))
                cpumask_set_cpu(cpu, &__cpu_primary_thread_mask);
 }
 #else