linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/2] clocksource: fix opencoded cpumask_next_wrap()
  2025-06-04 23:25 [PATCH 0/2] clocksource: use better cpumask API where appropriate Yury Norov
@ 2025-06-04 23:25 ` Yury Norov
  2025-06-05 18:11   ` John Stultz
  0 siblings, 1 reply; 8+ messages in thread
From: Yury Norov @ 2025-06-04 23:25 UTC (permalink / raw)
  To: linux-kernel, John Stultz, Thomas Gleixner, Stephen Boyd
  Cc: Yury Norov [NVIDIA]

From: Yury Norov [NVIDIA] <yury.norov@gmail.com>

cpumask_next_wrap() is more verbose and efficient comparing to
cpumask_next() followed by cpumask_first().

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

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 2e24ce884272..0aef0e349e49 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -584,9 +584,7 @@ static void clocksource_watchdog(struct timer_list *unused)
 	 * Cycle through CPUs to check if the CPUs stay synchronized
 	 * to each other.
 	 */
-	next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
-	if (next_cpu >= nr_cpu_ids)
-		next_cpu = cpumask_first(cpu_online_mask);
+	next_cpu = cpumask_next_wrap(raw_smp_processor_id(), cpu_online_mask);
 
 	/*
 	 * Arm timer if not already pending: could race with concurrent
-- 
2.43.0


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

* Re: [PATCH 2/2] clocksource: fix opencoded cpumask_next_wrap()
  2025-06-04 23:25 ` [PATCH 2/2] clocksource: fix opencoded cpumask_next_wrap() Yury Norov
@ 2025-06-05 18:11   ` John Stultz
  0 siblings, 0 replies; 8+ messages in thread
From: John Stultz @ 2025-06-05 18:11 UTC (permalink / raw)
  To: Yury Norov; +Cc: linux-kernel, Thomas Gleixner, Stephen Boyd

On Wed, Jun 4, 2025 at 4:25 PM Yury Norov <yury.norov@gmail.com> wrote:
>
> From: Yury Norov [NVIDIA] <yury.norov@gmail.com>
>
> cpumask_next_wrap() is more verbose and efficient comparing to
> cpumask_next() followed by cpumask_first().
>
> Signed-off-by: Yury Norov [NVIDIA] <yury.norov@gmail.com>
> ---
>  kernel/time/clocksource.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
> index 2e24ce884272..0aef0e349e49 100644
> --- a/kernel/time/clocksource.c
> +++ b/kernel/time/clocksource.c
> @@ -584,9 +584,7 @@ static void clocksource_watchdog(struct timer_list *unused)
>          * Cycle through CPUs to check if the CPUs stay synchronized
>          * to each other.
>          */
> -       next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
> -       if (next_cpu >= nr_cpu_ids)
> -               next_cpu = cpumask_first(cpu_online_mask);
> +       next_cpu = cpumask_next_wrap(raw_smp_processor_id(), cpu_online_mask);
>

This looks ok to me. The only nit is that often folks like to see the
$Subject line look like:
  $topic: Capitalized description.

So for this one:
  clocksource: Fix opencoded cpumask_next_wrap()

Acked-by: John Stultz <jstultz@google.com>
thanks
-john

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

* [PATCH 0/2] clocksource: Use better cpumask API where appropriate
@ 2025-06-07 14:11 Yury Norov
  2025-06-07 14:11 ` [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus() Yury Norov
  2025-06-07 14:11 ` [PATCH 2/2] clocksource: Fix opencoded cpumask_next_wrap() Yury Norov
  0 siblings, 2 replies; 8+ messages in thread
From: Yury Norov @ 2025-06-07 14:11 UTC (permalink / raw)
  To: linux-kernel, John Stultz, Thomas Gleixner, Stephen Boyd
  Cc: Yury Norov [NVIDIA]

From: Yury Norov [NVIDIA] <yury.norov@gmail.com>

The dedicated API works better and improves on readability

V2: Capitalize commit message names
v1: https://lore.kernel.org/all/20250604232550.40491-1-yury.norov@gmail.com/

Yury Norov [NVIDIA] (2):
  clocksource: Fix opencoded cpumask_any_but() in
    clocksource_verify_choose_cpus()
  clocksource: Fix opencoded cpumask_next_wrap()

 kernel/time/clocksource.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

-- 
2.43.0


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

* [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()
  2025-06-07 14:11 [PATCH 0/2] clocksource: Use better cpumask API where appropriate Yury Norov
@ 2025-06-07 14:11 ` Yury Norov
  2025-06-09 10:03   ` Thomas Gleixner
  2025-06-07 14:11 ` [PATCH 2/2] clocksource: Fix opencoded cpumask_next_wrap() Yury Norov
  1 sibling, 1 reply; 8+ messages in thread
From: Yury Norov @ 2025-06-07 14:11 UTC (permalink / raw)
  To: linux-kernel, John Stultz, Thomas Gleixner, Stephen Boyd
  Cc: Yury Norov [NVIDIA]

From: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>

cpumask_any_but() is more verbose than cpumask_first() followed by
cpumask_next(). Use it in clocksource_verify_choose_cpus().

Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>
---
 kernel/time/clocksource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index 6a8bc7da9062..a2f2e9f4d37b 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -323,9 +323,7 @@ static void clocksource_verify_choose_cpus(void)
 		return;
 
 	/* Make sure to select at least one CPU other than the current CPU. */
-	cpu = cpumask_first(cpu_online_mask);
-	if (cpu == smp_processor_id())
-		cpu = cpumask_next(cpu, cpu_online_mask);
+	cpu = cpumask_any_but(cpu_online_mask, smp_processor_id());
 	if (WARN_ON_ONCE(cpu >= nr_cpu_ids))
 		return;
 	cpumask_set_cpu(cpu, &cpus_chosen);
-- 
2.43.0


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

* [PATCH 2/2] clocksource: Fix opencoded cpumask_next_wrap()
  2025-06-07 14:11 [PATCH 0/2] clocksource: Use better cpumask API where appropriate Yury Norov
  2025-06-07 14:11 ` [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus() Yury Norov
@ 2025-06-07 14:11 ` Yury Norov
  1 sibling, 0 replies; 8+ messages in thread
From: Yury Norov @ 2025-06-07 14:11 UTC (permalink / raw)
  To: linux-kernel, John Stultz, Thomas Gleixner, Stephen Boyd
  Cc: Yury Norov [NVIDIA]

From: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>

cpumask_next_wrap() is more verbose and efficient comparing to
cpumask_next() followed by cpumask_first().

Acked-by: John Stultz <jstultz@google.com>
Signed-off-by: "Yury Norov [NVIDIA]" <yury.norov@gmail.com>
---
 kernel/time/clocksource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/time/clocksource.c b/kernel/time/clocksource.c
index a2f2e9f4d37b..e400fe150f9d 100644
--- a/kernel/time/clocksource.c
+++ b/kernel/time/clocksource.c
@@ -587,9 +587,7 @@ static void clocksource_watchdog(struct timer_list *unused)
 	 * Cycle through CPUs to check if the CPUs stay synchronized
 	 * to each other.
 	 */
-	next_cpu = cpumask_next(raw_smp_processor_id(), cpu_online_mask);
-	if (next_cpu >= nr_cpu_ids)
-		next_cpu = cpumask_first(cpu_online_mask);
+	next_cpu = cpumask_next_wrap(raw_smp_processor_id(), cpu_online_mask);
 
 	/*
 	 * Arm timer if not already pending: could race with concurrent
-- 
2.43.0


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

* Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()
  2025-06-07 14:11 ` [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus() Yury Norov
@ 2025-06-09 10:03   ` Thomas Gleixner
  2025-06-09 14:33     ` Yury Norov
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Gleixner @ 2025-06-09 10:03 UTC (permalink / raw)
  To: Yury Norov, linux-kernel, John Stultz, Stephen Boyd; +Cc: Yury Norov [NVIDIA]

On Sat, Jun 07 2025 at 10:11, Yury Norov wrote:

Why are you so obsessed to slap 'Fix' on every subject line?

This fixes absolutely nothing at all.

All it does is to replace a open coded sequence by appropriate
function. So describe the changes accurately.

Thanks,

        tglx

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

* Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()
  2025-06-09 10:03   ` Thomas Gleixner
@ 2025-06-09 14:33     ` Yury Norov
  2025-06-10  9:03       ` Thomas Gleixner
  0 siblings, 1 reply; 8+ messages in thread
From: Yury Norov @ 2025-06-09 14:33 UTC (permalink / raw)
  To: Thomas Gleixner; +Cc: linux-kernel, John Stultz, Stephen Boyd

On Mon, Jun 09, 2025 at 12:03:23PM +0200, Thomas Gleixner wrote:
> On Sat, Jun 07 2025 at 10:11, Yury Norov wrote:
> 
> Why are you so obsessed to slap 'Fix' on every subject line?
> 
> This fixes absolutely nothing at all.

Opencoding helpers is an error, isn't? That's why 'fix'.
 
> All it does is to replace a open coded sequence by appropriate
> function. So describe the changes accurately.

I'm not attached to words. If you prefer 'replace', I can resend with
the wording you like. Please advise.

Thanks,
Yury

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

* Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()
  2025-06-09 14:33     ` Yury Norov
@ 2025-06-10  9:03       ` Thomas Gleixner
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Gleixner @ 2025-06-10  9:03 UTC (permalink / raw)
  To: Yury Norov; +Cc: linux-kernel, John Stultz, Stephen Boyd

On Mon, Jun 09 2025 at 10:33, Yury Norov wrote:
> On Mon, Jun 09, 2025 at 12:03:23PM +0200, Thomas Gleixner wrote:
>> On Sat, Jun 07 2025 at 10:11, Yury Norov wrote:
>> 
>> Why are you so obsessed to slap 'Fix' on every subject line?
>> 
>> This fixes absolutely nothing at all.
>
> Opencoding helpers is an error, isn't? That's why 'fix'.

It's not. It's functionally correct, so there is no error. It's an
oversight in terms of code efficiency, not more.

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

end of thread, other threads:[~2025-06-10  9:03 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-07 14:11 [PATCH 0/2] clocksource: Use better cpumask API where appropriate Yury Norov
2025-06-07 14:11 ` [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus() Yury Norov
2025-06-09 10:03   ` Thomas Gleixner
2025-06-09 14:33     ` Yury Norov
2025-06-10  9:03       ` Thomas Gleixner
2025-06-07 14:11 ` [PATCH 2/2] clocksource: Fix opencoded cpumask_next_wrap() Yury Norov
  -- strict thread matches above, loose matches on Subject: below --
2025-06-04 23:25 [PATCH 0/2] clocksource: use better cpumask API where appropriate Yury Norov
2025-06-04 23:25 ` [PATCH 2/2] clocksource: fix opencoded cpumask_next_wrap() Yury Norov
2025-06-05 18:11   ` John Stultz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).