clocksource: use better cpumask API where appropriate
cover clocksource: use better cpumask API where appropriate
From: Yury Norov [NVIDIA] <[email protected]>
The dedicated API works better and improves on readability.
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
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
@@ -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
Re: [PATCH 1/2] clocksource: fix opencoded cpumask_any_but() in clocksource_verify_choose_cpus()
Quoted 16 lines · Yury Norov
From: Yury Norov [NVIDIA] <[email protected]>
cpumask_any_but()is more verbose thancpumask_first()followed bycpumask_next(). Use it inclocksource_verify_choose_cpus().Signed-off-by Yury Norov [NVIDIA] <[email protected]>--- kernel/time/clocksource.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/time/clocksource.c +0
-0
kernel/time/clocksource.c static void clocksource_verify_choose_cpus(void) · line 329
Quoted 10 lines
kernel/time/clocksource.c +1
-3@@ -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);
Same nit comment from the other patch, just need to capitalize the commit description in the subject.
"clocksource: Fix opencoded..."
thanks
-john
PATCH 2/2 clocksource: fix opencoded cpumask_next_wrap()
In reply to Yury NorovFrom: 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
@@ -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
Signature · 1 line
2.43.0
Re: [PATCH 2/2] clocksource: fix opencoded cpumask_next_wrap()
Quoted 16 lines · Yury Norov
From: Yury Norov [NVIDIA] <[email protected]>
cpumask_next_wrap()is more verbose and efficient comparing tocpumask_next()followed bycpumask_first().Signed-off-by Yury Norov [NVIDIA] <[email protected]>--- kernel/time/clocksource.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)kernel/time/clocksource.c +0
-0
kernel/time/clocksource.c static void clocksource_watchdog(struct timer_list *unused) · line 588
Quoted 8 lines
kernel/time/clocksource.c +1
-3@@ -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()
thanks
-john