Skip to content

Commit f5c54f7

Browse files
committed
cpumask: Add a x86-specific cpumask_clear_cpu() helper
Add a x86-specific cpumask_clear_cpu() helper which will be used in places where the explicit KASAN-instrumentation in the *_bit() helpers is unwanted. Also, always inline two more cpumask generic helpers. allyesconfig: text data bss dec hex filename 190553143 159425889 32076404 382055436 16c5b40c vmlinux.before 190551812 159424945 32076404 382053161 16c5ab29 vmlinux.after Signed-off-by: Borislav Petkov <[email protected]> Acked-by: Marco Elver <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1c6f9ec commit f5c54f7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

arch/x86/include/asm/cpumask.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,21 @@ static __always_inline bool arch_cpu_online(int cpu)
2020
{
2121
return arch_test_bit(cpu, cpumask_bits(cpu_online_mask));
2222
}
23+
24+
static __always_inline void arch_cpumask_clear_cpu(int cpu, struct cpumask *dstp)
25+
{
26+
arch_clear_bit(cpumask_check(cpu), cpumask_bits(dstp));
27+
}
2328
#else
2429
static __always_inline bool arch_cpu_online(int cpu)
2530
{
2631
return cpu == 0;
2732
}
33+
34+
static __always_inline void arch_cpumask_clear_cpu(int cpu, struct cpumask *dstp)
35+
{
36+
return;
37+
}
2838
#endif
2939

3040
#define arch_cpu_is_offline(cpu) unlikely(!arch_cpu_online(cpu))

include/linux/cpumask.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,15 +102,15 @@ extern atomic_t __num_online_cpus;
102102

103103
extern cpumask_t cpus_booted_once_mask;
104104

105-
static inline void cpu_max_bits_warn(unsigned int cpu, unsigned int bits)
105+
static __always_inline void cpu_max_bits_warn(unsigned int cpu, unsigned int bits)
106106
{
107107
#ifdef CONFIG_DEBUG_PER_CPU_MAPS
108108
WARN_ON_ONCE(cpu >= bits);
109109
#endif /* CONFIG_DEBUG_PER_CPU_MAPS */
110110
}
111111

112112
/* verify cpu argument to cpumask_* operators */
113-
static inline unsigned int cpumask_check(unsigned int cpu)
113+
static __always_inline unsigned int cpumask_check(unsigned int cpu)
114114
{
115115
cpu_max_bits_warn(cpu, nr_cpumask_bits);
116116
return cpu;

0 commit comments

Comments
 (0)