mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] watchdog/wdt-main: Use cpumask_of() to avoid cpumask var on stack
@ 2024-04-10 13:13 Dawei Li
  2024-04-10 14:48 ` Guenter Roeck
  0 siblings, 1 reply; 2+ messages in thread
From: Dawei Li @ 2024-04-10 13:13 UTC (permalink / raw)
  To: wim, linux; +Cc: linux-watchdog, linux-kernel, Dawei Li

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.

Use cpumask_of() to avoid the need for a temporary cpumask on the stack

Signed-off-by: Dawei Li <set_pte_at@outlook.com>
---
 drivers/watchdog/octeon-wdt-main.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/watchdog/octeon-wdt-main.c b/drivers/watchdog/octeon-wdt-main.c
index 0fe71f7e66d5..52d49e4e35a0 100644
--- a/drivers/watchdog/octeon-wdt-main.c
+++ b/drivers/watchdog/octeon-wdt-main.c
@@ -381,11 +381,7 @@ static int octeon_wdt_cpu_online(unsigned int cpu)
 
 	/* Must set the irq affinity here */
 	if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
-		cpumask_t mask;
-
-		cpumask_clear(&mask);
-		cpumask_set_cpu(cpu, &mask);
-		irq_set_affinity(irq, &mask);
+		irq_set_affinity(irq, cpumask_of(cpu));
 	}
 
 	cpumask_set_cpu(cpu, &irq_enabled_cpus);
-- 
2.25.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] watchdog/wdt-main: Use cpumask_of() to avoid cpumask var on stack
  2024-04-10 13:13 [PATCH] watchdog/wdt-main: Use cpumask_of() to avoid cpumask var on stack Dawei Li
@ 2024-04-10 14:48 ` Guenter Roeck
  0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2024-04-10 14:48 UTC (permalink / raw)
  To: Dawei Li; +Cc: wim, linux-watchdog, linux-kernel

On Wed, Apr 10, 2024 at 09:13:59PM +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.
> 
> Use cpumask_of() to avoid the need for a temporary cpumask on the stack
> 
> Signed-off-by: Dawei Li <set_pte_at@outlook.com>

Reviewed-by: Guenter Roeck <linux@roeck-us.net>

> ---
>  drivers/watchdog/octeon-wdt-main.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
> 
> diff --git a/drivers/watchdog/octeon-wdt-main.c b/drivers/watchdog/octeon-wdt-main.c
> index 0fe71f7e66d5..52d49e4e35a0 100644
> --- a/drivers/watchdog/octeon-wdt-main.c
> +++ b/drivers/watchdog/octeon-wdt-main.c
> @@ -381,11 +381,7 @@ static int octeon_wdt_cpu_online(unsigned int cpu)
>  
>  	/* Must set the irq affinity here */
>  	if (octeon_has_feature(OCTEON_FEATURE_CIU3)) {
> -		cpumask_t mask;
> -
> -		cpumask_clear(&mask);
> -		cpumask_set_cpu(cpu, &mask);
> -		irq_set_affinity(irq, &mask);
> +		irq_set_affinity(irq, cpumask_of(cpu));
>  	}
>  
>  	cpumask_set_cpu(cpu, &irq_enabled_cpus);
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-10 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-10 13:13 [PATCH] watchdog/wdt-main: Use cpumask_of() to avoid cpumask var on stack Dawei Li
2024-04-10 14:48 ` Guenter Roeck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®