Skip to contentSkip to conversation

clocksource: Use better cpumask API where appropriate

PATCH Superseded Yury Norov 2 participants 6 messages Jun 7, 2025 – Jun 10, 2025 Timekeeping, clocksource core, NTP, alarmtimer

lore
Share & tools
lore

Yury Norov

author
#0 lore raw

cover clocksource: Use better cpumask API where appropriate

From: Yury Norov [NVIDIA] <[email protected]>

The dedicated API works better and improves on readability

V2: Capitalize commit message names
v1: https://lore.kernel.org/all/[email protected]/

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(-)
Signature · 1 line
2.43.0
author
#1 lore raw

PATCH 1/2 clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()

From: "Yury Norov [NVIDIA]" <[email protected]>

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

---
 kernel/time/clocksource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/time/clocksource.c +1 -3
index 6a8bc7da9062..a2f2e9f4d37b 100644
@@ -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);
Signature · 1 line
2.43.0
#2 lore raw

Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()

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

author
#3 lore raw

Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()

Quoted 5 lines · Thomas Gleixner

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'.

Quoted 2 lines

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

#4 lore raw

Re: [PATCH 1/2] clocksource: Fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()

Quoted 8 lines · Yury Norov
Quoted 5 lines · Thomas Gleixner

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.

author
#5 lore raw

PATCH 2/2 clocksource: Fix opencoded cpumask_next_wrap()

In reply to Yury Norov

From: "Yury Norov [NVIDIA]" <[email protected]>

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

---
 kernel/time/clocksource.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/time/clocksource.c +1 -3
index a2f2e9f4d37b..e400fe150f9d 100644
@@ -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
Signature · 1 line
2.43.0