mirror of
https://github.com/torvalds/linux
synced 2024-10-15 15:59:15 +00:00
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
This commit is contained in:
parent
c1fc6484e1
commit
7537b90c00
|
@ -1097,25 +1097,22 @@ int get_nohz_timer_target(void)
|
|||
|
||||
hk_mask = housekeeping_cpumask(HK_TYPE_TIMER);
|
||||
|
||||
rcu_read_lock();
|
||||
guard(rcu)();
|
||||
|
||||
for_each_domain(cpu, sd) {
|
||||
for_each_cpu_and(i, sched_domain_span(sd), hk_mask) {
|
||||
if (cpu == i)
|
||||
continue;
|
||||
|
||||
if (!idle_cpu(i)) {
|
||||
cpu = i;
|
||||
goto unlock;
|
||||
}
|
||||
if (!idle_cpu(i))
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
if (default_cpu == -1)
|
||||
default_cpu = housekeeping_any_cpu(HK_TYPE_TIMER);
|
||||
cpu = default_cpu;
|
||||
unlock:
|
||||
rcu_read_unlock();
|
||||
return cpu;
|
||||
|
||||
return default_cpu;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in a new issue