Skip to content

Commit 227bbaa

Browse files
Nysal Jan K.Ampe
authored andcommitted
powerpc/topology: Check if a core is online
topology_is_core_online() checks if the core a CPU belongs to is online. The core is online if at least one of the sibling CPUs is online. The first CPU of an online core is also online in the common case, so this should be fairly quick. Fixes: 73c58e7 ("powerpc: Add HOTPLUG_SMT support") Signed-off-by: Nysal Jan K.A <nysal@linux.ibm.com> Reviewed-by: Shrikanth Hegde <sshegde@linux.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://msgid.link/20240731030126.956210-3-nysal@linux.ibm.com
1 parent 6c17ea1 commit 227bbaa

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/powerpc/include/asm/topology.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ static inline int cpu_to_coregroup_id(int cpu)
145145

146146
#ifdef CONFIG_HOTPLUG_SMT
147147
#include <linux/cpu_smt.h>
148+
#include <linux/cpumask.h>
148149
#include <asm/cputhreads.h>
149150

150151
static inline bool topology_is_primary_thread(unsigned int cpu)
@@ -156,6 +157,18 @@ static inline bool topology_smt_thread_allowed(unsigned int cpu)
156157
{
157158
return cpu_thread_in_core(cpu) < cpu_smt_num_threads;
158159
}
160+
161+
#define topology_is_core_online topology_is_core_online
162+
static inline bool topology_is_core_online(unsigned int cpu)
163+
{
164+
int i, first_cpu = cpu_first_thread_sibling(cpu);
165+
166+
for (i = first_cpu; i < first_cpu + threads_per_core; ++i) {
167+
if (cpu_online(i))
168+
return true;
169+
}
170+
return false;
171+
}
159172
#endif
160173

161174
#endif /* __KERNEL__ */

0 commit comments

Comments
 (0)