Fix IRQ flag handling naming
[linux-2.6/cjktty.git] / arch / powerpc / include / asm / cputhreads.h
bloba8e18447c62b967d381a09fb5a7f0857753dbd19
1 #ifndef _ASM_POWERPC_CPUTHREADS_H
2 #define _ASM_POWERPC_CPUTHREADS_H
4 #include <linux/cpumask.h>
6 /*
7 * Mapping of threads to cores
9 * Note: This implementation is limited to a power of 2 number of
10 * threads per core and the same number for each core in the system
11 * (though it would work if some processors had less threads as long
12 * as the CPU numbers are still allocated, just not brought offline).
14 * However, the API allows for a different implementation in the future
15 * if needed, as long as you only use the functions and not the variables
16 * directly.
19 #ifdef CONFIG_SMP
20 extern int threads_per_core;
21 extern int threads_shift;
22 extern cpumask_t threads_core_mask;
23 #else
24 #define threads_per_core 1
25 #define threads_shift 0
26 #define threads_core_mask (CPU_MASK_CPU0)
27 #endif
29 /* cpu_thread_mask_to_cores - Return a cpumask of one per cores
30 * hit by the argument
32 * @threads: a cpumask of threads
34 * This function returns a cpumask which will have one "cpu" (or thread)
35 * bit set for each core that has at least one thread set in the argument.
37 * This can typically be used for things like IPI for tlb invalidations
38 * since those need to be done only once per core/TLB
40 static inline cpumask_t cpu_thread_mask_to_cores(cpumask_t threads)
42 cpumask_t tmp, res;
43 int i;
45 res = CPU_MASK_NONE;
46 for (i = 0; i < NR_CPUS; i += threads_per_core) {
47 cpus_shift_left(tmp, threads_core_mask, i);
48 if (cpus_intersects(threads, tmp))
49 cpu_set(i, res);
51 return res;
54 static inline int cpu_nr_cores(void)
56 return NR_CPUS >> threads_shift;
59 static inline cpumask_t cpu_online_cores_map(void)
61 return cpu_thread_mask_to_cores(cpu_online_map);
64 static inline int cpu_thread_to_core(int cpu)
66 return cpu >> threads_shift;
69 static inline int cpu_thread_in_core(int cpu)
71 return cpu & (threads_per_core - 1);
74 static inline int cpu_first_thread_in_core(int cpu)
76 return cpu & ~(threads_per_core - 1);
79 static inline int cpu_last_thread_in_core(int cpu)
81 return cpu | (threads_per_core - 1);
86 #endif /* _ASM_POWERPC_CPUTHREADS_H */