xref: /linux/arch/x86/include/asm/cpumask.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_X86_CPUMASK_H
3 #define _ASM_X86_CPUMASK_H
4 #ifndef __ASSEMBLY__
5 #include <linux/cpumask.h>
6 
7 extern void setup_cpu_local_masks(void);
8 
9 /*
10  * NMI and MCE exceptions need cpu_is_offline() _really_ early,
11  * provide an arch_ special for them to avoid instrumentation.
12  */
13 #if NR_CPUS > 1
14 static __always_inline bool arch_cpu_online(int cpu)
15 {
16 	return arch_test_bit(cpu, cpumask_bits(cpu_online_mask));
17 }
18 
19 static __always_inline void arch_cpumask_clear_cpu(int cpu, struct cpumask *dstp)
20 {
21 	arch_clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
22 }
23 #else
24 static __always_inline bool arch_cpu_online(int cpu)
25 {
26 	return cpu == 0;
27 }
28 
29 static __always_inline void arch_cpumask_clear_cpu(int cpu, struct cpumask *dstp)
30 {
31 	return;
32 }
33 #endif
34 
35 #define arch_cpu_is_offline(cpu)	unlikely(!arch_cpu_online(cpu))
36 
37 #endif /* __ASSEMBLY__ */
38 #endif /* _ASM_X86_CPUMASK_H */
39