1 #ifndef _ASM_POWERPC_CPUTHREADS_H
2 #define _ASM_POWERPC_CPUTHREADS_H
4 #include <linux/cpumask.h>
7 * Mapping of threads to cores
11 extern int threads_per_core
;
12 extern int threads_shift
;
13 extern cpumask_t threads_core_mask
;
15 #define threads_per_core 1
16 #define threads_shift 0
17 #define threads_core_mask (CPU_MASK_CPU0)
20 /* cpu_thread_mask_to_cores - Return a cpumask of one per cores
23 * @threads: a cpumask of threads
25 * This function returns a cpumask which will have one "cpu" (or thread)
26 * bit set for each core that has at least one thread set in the argument.
28 * This can typically be used for things like IPI for tlb invalidations
29 * since those need to be done only once per core/TLB
31 static inline cpumask_t
cpu_thread_mask_to_cores(cpumask_t threads
)
37 for (i
= 0; i
< NR_CPUS
; i
+= threads_per_core
) {
38 cpus_shift_left(tmp
, threads_core_mask
, i
);
39 if (cpus_intersects(threads
, tmp
))
45 static inline int cpu_nr_cores(void)
47 return NR_CPUS
>> threads_shift
;
50 static inline cpumask_t
cpu_online_cores_map(void)
52 return cpu_thread_mask_to_cores(cpu_online_map
);
55 static inline int cpu_thread_to_core(int cpu
)
57 return cpu
>> threads_shift
;
60 static inline int cpu_thread_in_core(int cpu
)
62 return cpu
& (threads_per_core
- 1);
65 static inline int cpu_first_thread_in_core(int cpu
)
67 return cpu
& ~(threads_per_core
- 1);
70 #endif /* _ASM_POWERPC_CPUTHREADS_H */