[PATCH] x86/smpboot: Mark memory allocations in smp_prepare_cpus_common __GFP_NOFAIL
From: Nikita Kiryushin
Date: Wed Jul 10 2024 - 14:45:46 EST
As of now, zalloc_cpumask_var_node for various maps in
smp_prepare_cpus_common is not checked.
As memory allocations here are critical and there is no reasonable
allocation failure policy, the allocations should never fail.
Use __GFP_NOFAIL flag, as suggested in
https://lore.kernel.org/all/ZhaUZFY5MUyy6hWK@xxxxxxxxx/
Signed-off-by: Nikita Kiryushin <kiryushin@xxxxxxxx>
---
arch/x86/kernel/smpboot.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
index 0c35207320cb..76fabb74b8ea 100644
--- a/arch/x86/kernel/smpboot.c
+++ b/arch/x86/kernel/smpboot.c
@@ -1044,11 +1044,11 @@ void __init smp_prepare_cpus_common(void)
for_each_possible_cpu(cpu) {
node = cpu_to_node(cpu);
- zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, cpu), GFP_KERNEL, node);
- zalloc_cpumask_var_node(&per_cpu(cpu_core_map, cpu), GFP_KERNEL, node);
- zalloc_cpumask_var_node(&per_cpu(cpu_die_map, cpu), GFP_KERNEL, node);
- zalloc_cpumask_var_node(&per_cpu(cpu_llc_shared_map, cpu), GFP_KERNEL, node);
- zalloc_cpumask_var_node(&per_cpu(cpu_l2c_shared_map, cpu), GFP_KERNEL, node);
+ zalloc_cpumask_var_node(&per_cpu(cpu_sibling_map, cpu), GFP_KERNEL | __GFP_NOFAIL, node);
+ zalloc_cpumask_var_node(&per_cpu(cpu_core_map, cpu), GFP_KERNEL | __GFP_NOFAIL, node);
+ zalloc_cpumask_var_node(&per_cpu(cpu_die_map, cpu), GFP_KERNEL | __GFP_NOFAIL, node);
+ zalloc_cpumask_var_node(&per_cpu(cpu_llc_shared_map, cpu), GFP_KERNEL | __GFP_NOFAIL, node);
+ zalloc_cpumask_var_node(&per_cpu(cpu_l2c_shared_map, cpu), GFP_KERNEL | __GFP_NOFAIL, node);
}
set_cpu_sibling_map(0);
--
2.34.1