Skip to content

Commit 7537b90

Browse files
author
Peter Zijlstra
committed
sched: Simplify get_nohz_timer_target()
Use guards to reduce gotos and simplify control flow. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org> Reviewed-by: Valentin Schneider <vschneid@redhat.com> Link: https://lore.kernel.org/r/20230801211811.828443100@infradead.org
1 parent c1fc648 commit 7537b90

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

kernel/sched/core.c

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,25 +1097,22 @@ int get_nohz_timer_target(void)
10971097

10981098
hk_mask = housekeeping_cpumask(HK_TYPE_TIMER);
10991099

1100-
rcu_read_lock();
1100+
guard(rcu)();
1101+
11011102
for_each_domain(cpu, sd) {
11021103
for_each_cpu_and(i, sched_domain_span(sd), hk_mask) {
11031104
if (cpu == i)
11041105
continue;
11051106

1106-
if (!idle_cpu(i)) {
1107-
cpu = i;
1108-
goto unlock;
1109-
}
1107+
if (!idle_cpu(i))
1108+
return i;
11101109
}
11111110
}
11121111

11131112
if (default_cpu == -1)
11141113
default_cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
1115-
cpu = default_cpu;
1116-
unlock:
1117-
rcu_read_unlock();
1118-
return cpu;
1114+
1115+
return default_cpu;
11191116
}
11201117

11211118
/*

0 commit comments

Comments
 (0)