Skip to content

Commit 5e40fb2

Browse files
committed
x86/cpu/topology: Simplify cpu_mark_primary_thread()
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
1 parent 882e0cf commit 5e40fb2

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

arch/x86/kernel/cpu/topology.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
7676
#ifdef CONFIG_SMP
7777
static void cpu_mark_primary_thread(unsigned int cpu, unsigned int apicid)
7878
{
79-
/* Isolate the SMT bit(s) in the APICID and check for 0 */
80-
u32 mask = (1U << (fls(smp_num_siblings) - 1)) - 1;
81-
82-
if (smp_num_siblings == 1 || !(apicid & mask))
79+
if (!(apicid & (smp_num_siblings - 1)))
8380
cpumask_set_cpu(cpu, &__cpu_primary_thread_mask);
8481
}
8582
#else

0 commit comments

Comments
 (0)