x86, cpu hotplug, use cpumask stack safe variant cpumask_var_t in check_irq_vectors_for_cpu_disable()
PATCH 1/1 x86, cpu hotplug, use cpumask stack safe variant cpumask_var_t in check_irq_vectors_for_cpu_disable()
kbuild, 0day kernel build service, outputs the warning:
arch/x86/kernel/irq.c:333:1: warning: the frame size of 2056 bytes is larger than 2048 bytes [-Wframe-larger-than=]
because check_irq_vectors_for_cpu_disable() allocates two cpumasks on the stack. Fix this by using cpumask_var_t, the cpumask stack safe variant.
--- arch/x86/kernel/irq.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
arch/x86/kernel/irq.c +25 -10
@@ -269,15 +269,25 @@ EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq);*/ int check_irq_vectors_for_cpu_disable (void ) { -int irq, cpu; +int irq, cpu, ret =0 ;unsigned int this_cpu, vector, this_count, count;struct irq_desc *desc;struct irq_data *data; -struct cpumask affinity_new, online_new; +cpumask_var_t affinity_new, online_new; + +if (!alloc_cpumask_var (&online_new,GFP_KERNEL )){ + ret = -ENOMEM ; + goto out; + } + +if (!alloc_cpumask_var (&affinity_new,GFP_KERNEL )) { + ret = -ENOMEM ; + goto free_online_new; + } this_cpu =smp_processor_id (); -cpumask_copy (&online_new, cpu_online_mask); -cpu_clear (this_cpu, online_new); +cpumask_copy (online_new, cpu_online_mask); +__cpu_clear (this_cpu, online_new); this_count =0 ;for (vector =FIRST_EXTERNAL_VECTOR ; vector <NR_VECTORS ; vector++) {
@@ -285,8 +295,8 @@ int check_irq_vectors_for_cpu_disable(void)if (irq >=0 ) { desc =irq_to_desc (irq); data =irq_desc_get_irq_data (desc); -cpumask_copy (&affinity_new, data->affinity); -cpu_clear (this_cpu, affinity_new); +cpumask_copy (affinity_new, data->affinity); +__cpu_clear (this_cpu, affinity_new);/* Do not count inactive or per-cpu irqs. */ if (!irq_has_action (irq) ||irqd_is_per_cpu (data))
@@ -307,8 +317,8 @@ int check_irq_vectors_for_cpu_disable(void)* mask is not zero; that is the down'd cpu is the * last online cpu in a user set affinity mask. */ -if (cpumask_empty (&affinity_new) || - !cpumask_subset (&affinity_new, &online_new)) +if (cpumask_empty (affinity_new) || + !cpumask_subset (affinity_new, online_new)) this_count++; } }
@@ -327,9 +337,14 @@ int check_irq_vectors_for_cpu_disable(void)if (count < this_count) {pr_warn ("CPU %d disable failed: CPU has %u vectors assigned and there are only %u available.\n" , this_cpu, this_count, count); -return -ERANGE ; + ret = -ERANGE ; } -return 0 ; + +free_cpumask_var (affinity_new); +free_online_new: +free_cpumask_var (online_new); +out: +return ret; }/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
Signature · 1 line
1.7.9.3
On Fri, Jan 17, 2014 at 08:39:21AM -0500, Prarit Bhargava wrote:
[...]
arch/x86/kernel/irq.c EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq); · line 286
Quoted 11 lines
arch/x86/kernel/irq.c +10
-0+ +if (!alloc_cpumask_var (&online_new,GFP_KERNEL )){ + ret = -ENOMEM ; + goto out; + } + +if (!alloc_cpumask_var (&affinity_new,GFP_KERNEL )) { + ret = -ENOMEM ; + goto free_online_new; + }
This function is protected by stop_machine, which means the interrupts have been disabled, so GFP_KERNEL is not reliable.
PATCH 1/1 x86, cpu hotplug, use cpumask stack safe variant cpumask_var_t in check_irq_vectors_for_cpu_disable() [v2]
kbuild, 0day kernel build service, outputs the warning:
arch/x86/kernel/irq.c:333:1: warning: the frame size of 2056 bytes is larger than 2048 bytes [-Wframe-larger-than=]
because check_irq_vectors_for_cpu_disable() allocates two cpumasks on the stack. Fix this by using cpumask_var_t, the cpumask stack safe variant.
[v2]: switch from GFP_KERNEL to GFP_ATOMIC
--- arch/x86/kernel/irq.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-)
arch/x86/kernel/irq.c +25 -10
@@ -269,15 +269,25 @@ EXPORT_SYMBOL_GPL(vector_used_by_percpu_irq);*/ int check_irq_vectors_for_cpu_disable (void ) { -int irq, cpu; +int irq, cpu, ret =0 ;unsigned int this_cpu, vector, this_count, count;struct irq_desc *desc;struct irq_data *data; -struct cpumask affinity_new, online_new; +cpumask_var_t affinity_new, online_new; + +if (!alloc_cpumask_var (&online_new,GFP_ATOMIC )){ + ret = -ENOMEM ; + goto out; + } + +if (!alloc_cpumask_var (&affinity_new,GFP_ATOMIC )) { + ret = -ENOMEM ; + goto free_online_new; + } this_cpu =smp_processor_id (); -cpumask_copy (&online_new, cpu_online_mask); -cpu_clear (this_cpu, online_new); +cpumask_copy (online_new, cpu_online_mask); +__cpu_clear (this_cpu, online_new); this_count =0 ;for (vector =FIRST_EXTERNAL_VECTOR ; vector <NR_VECTORS ; vector++) {
@@ -285,8 +295,8 @@ int check_irq_vectors_for_cpu_disable(void)if (irq >=0 ) { desc =irq_to_desc (irq); data =irq_desc_get_irq_data (desc); -cpumask_copy (&affinity_new, data->affinity); -cpu_clear (this_cpu, affinity_new); +cpumask_copy (affinity_new, data->affinity); +__cpu_clear (this_cpu, affinity_new);/* Do not count inactive or per-cpu irqs. */ if (!irq_has_action (irq) ||irqd_is_per_cpu (data))
@@ -307,8 +317,8 @@ int check_irq_vectors_for_cpu_disable(void)* mask is not zero; that is the down'd cpu is the * last online cpu in a user set affinity mask. */ -if (cpumask_empty (&affinity_new) || - !cpumask_subset (&affinity_new, &online_new)) +if (cpumask_empty (affinity_new) || + !cpumask_subset (affinity_new, online_new)) this_count++; } }
@@ -327,9 +337,14 @@ int check_irq_vectors_for_cpu_disable(void)if (count < this_count) {pr_warn ("CPU %d disable failed: CPU has %u vectors assigned and there are only %u available.\n" , this_cpu, this_count, count); -return -ERANGE ; + ret = -ERANGE ; } -return 0 ; + +free_cpumask_var (affinity_new); +free_online_new: +free_cpumask_var (online_new); +out: +return ret; }/* A cpu has been removed from cpu_online_mask. Reset irq affinities. */
Signature · 1 line
1.7.9.3
Re: [PATCH] x86, cpu hotplug, use cpumask stack safe variant cpumask_var_t in check_irq_vectors_for_cpu_disable() [v2]
Quoted 26 lines · Prarit Bhargava
Subject: [PATCH] x86, cpu hotplug, use cpumask stack safe variant
cpumask_var_tincheck_irq_vectors_for_cpu_disable()[v2]kbuild, 0day kernel build service, outputs the warning:
arch/x86/kernel/irq.c:333:1: warning: the frame size of 2056 bytes is larger than 2048 bytes [-Wframe-larger-than=]because
check_irq_vectors_for_cpu_disable()allocates two cpumasks on the stack. Fix this by usingcpumask_var_t, the cpumask stack safe variant.Signed-off-by Prarit Bhargava <[email protected]>Cc Andi Kleen <[email protected]>Cc Michel Lespinasse <[email protected]>Cc Seiji Aguchi <[email protected]>Cc Yang Zhang <[email protected]>Cc Paul Gortmaker <[email protected]>Cc Janet Morgan <[email protected]>Cc Tony Luck <[email protected]>Cc Ruiv Wang <[email protected]>Cc Gong Chen <[email protected]>Cc H. Peter Anvin <[email protected]>Cc Gong Chen <[email protected]>Cc Fengguang Wu <[email protected]>
Quoted 1 line
[v2]: switch from
GFP_KERNELtoGFP_ATOMIC