[PATCH v2 3/7] sparc/of: Remove on-stack cpumask var

Dawei Li posted 7 patches 1 year, 9 months ago
There is a newer version of this series
[PATCH v2 3/7] sparc/of: Remove on-stack cpumask var
Posted by Dawei Li 1 year, 9 months ago
In general it's preferable to avoid placing cpumasks on the stack, as
for large values of NR_CPUS these can consume significant amounts of
stack space and make stack overflows more likely.

@cpumask of irq_set_affinity() is read-only and free of change, drop
unneeded cpumask var.

Signed-off-by: Dawei Li <dawei.li@shingroup.cn>
---
 arch/sparc/kernel/of_device_64.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
index c350c58c7f69..f98c2901f335 100644
--- a/arch/sparc/kernel/of_device_64.c
+++ b/arch/sparc/kernel/of_device_64.c
@@ -624,10 +624,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op,
 out:
 	nid = of_node_to_nid(dp);
 	if (nid != -1) {
-		cpumask_t numa_mask;
-
-		cpumask_copy(&numa_mask, cpumask_of_node(nid));
-		irq_set_affinity(irq, &numa_mask);
+		irq_set_affinity(irq, cpumask_of_node(nid));
 	}
 
 	return irq;
-- 
2.27.0
Re: [PATCH v2 3/7] sparc/of: Remove on-stack cpumask var
Posted by Sam Ravnborg 1 year, 9 months ago
On Sat, Apr 20, 2024 at 01:15:43PM +0800, Dawei Li wrote:
> In general it's preferable to avoid placing cpumasks on the stack, as
> for large values of NR_CPUS these can consume significant amounts of
> stack space and make stack overflows more likely.
> 
> @cpumask of irq_set_affinity() is read-only and free of change, drop
> unneeded cpumask var.
> 
> Signed-off-by: Dawei Li <dawei.li@shingroup.cn>

Reviewed-by: Sam Ravnborg <sam@ravnborg.org>

> ---
>  arch/sparc/kernel/of_device_64.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c
> index c350c58c7f69..f98c2901f335 100644
> --- a/arch/sparc/kernel/of_device_64.c
> +++ b/arch/sparc/kernel/of_device_64.c
> @@ -624,10 +624,7 @@ static unsigned int __init build_one_device_irq(struct platform_device *op,
>  out:
>  	nid = of_node_to_nid(dp);
>  	if (nid != -1) {
> -		cpumask_t numa_mask;
> -
> -		cpumask_copy(&numa_mask, cpumask_of_node(nid));
> -		irq_set_affinity(irq, &numa_mask);
> +		irq_set_affinity(irq, cpumask_of_node(nid));
>  	}
>  
>  	return irq;
> -- 
> 2.27.0