[PATCH] watchdog: fix opencoded cpumask_next_wrap() in watchdog_next_cpu()

Yury Norov posted 1 patch 6 months, 2 weeks ago
kernel/watchdog_buddy.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
[PATCH] watchdog: fix opencoded cpumask_next_wrap() in watchdog_next_cpu()
Posted by Yury Norov 6 months, 2 weeks ago
From: Yury Norov [NVIDIA] <yury.norov@gmail.com>

The dedicated helper is more verbose and efficient comparing to
cpumask_next() followed by cpumask_first().

Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
---
 kernel/watchdog_buddy.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/kernel/watchdog_buddy.c b/kernel/watchdog_buddy.c
index 34dbfe091f4b..ee754d767c21 100644
--- a/kernel/watchdog_buddy.c
+++ b/kernel/watchdog_buddy.c
@@ -12,10 +12,7 @@ static unsigned int watchdog_next_cpu(unsigned int cpu)
 {
 	unsigned int next_cpu;
 
-	next_cpu = cpumask_next(cpu, &watchdog_cpus);
-	if (next_cpu >= nr_cpu_ids)
-		next_cpu = cpumask_first(&watchdog_cpus);
-
+	next_cpu = cpumask_next_wrap(cpu, &watchdog_cpus);
 	if (next_cpu == cpu)
 		return nr_cpu_ids;
 
-- 
2.43.0
Re: [PATCH] watchdog: fix opencoded cpumask_next_wrap() in watchdog_next_cpu()
Posted by Doug Anderson 6 months, 1 week ago
Hi,

On Wed, Jun 4, 2025 at 5:12 PM Yury Norov <yury.norov@gmail.com> wrote:
>
> From: Yury Norov [NVIDIA] <yury.norov@gmail.com>
>
> The dedicated helper is more verbose and efficient comparing to
> cpumask_next() followed by cpumask_first().
>
> Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> ---
>  kernel/watchdog_buddy.c | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)

Reviewed-by: Douglas Anderson <dianders@chromium.org>
Re: [PATCH] watchdog: fix opencoded cpumask_next_wrap() in watchdog_next_cpu()
Posted by Yury Norov 6 months ago
On Mon, Jun 09, 2025 at 10:16:51AM -0700, Doug Anderson wrote:
> Hi,
> 
> On Wed, Jun 4, 2025 at 5:12 PM Yury Norov <yury.norov@gmail.com> wrote:
> >
> > From: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> >
> > The dedicated helper is more verbose and efficient comparing to
> > cpumask_next() followed by cpumask_first().
> >
> > Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> > ---
> >  kernel/watchdog_buddy.c | 5 +----
> >  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> Reviewed-by: Douglas Anderson <dianders@chromium.org>

Thanks, Douglas. Adding in bitmap-for-next for testing.