Skip to content

Commit

Permalink
timers: Simplify code in run_local_timers()
Browse files Browse the repository at this point in the history
The logic for raising a softirq the way it is implemented right now, is
readable for two timer bases. When increasing the number of timer bases,
code gets harder to read. With the introduction of the timer migration
hierarchy, there will be three timer bases.

Therefore restructure the code to use a loop. No functional change.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20240221090548.36600-9-anna-maria@linutronix.de
  • Loading branch information
Anna-Maria Behnsen authored and Thomas Gleixner committed Feb 22, 2024
1 parent aae55e9 commit af68cb3
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions kernel/time/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2180,16 +2180,14 @@ static void run_local_timers(void)
struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);

hrtimer_run_queues();
/* Raise the softirq only if required. */
if (time_before(jiffies, base->next_expiry)) {
if (!IS_ENABLED(CONFIG_NO_HZ_COMMON))
return;
/* CPU is awake, so check the deferrable base. */
base++;
if (time_before(jiffies, base->next_expiry))

for (int i = 0; i < NR_BASES; i++, base++) {
/* Raise the softirq only if required. */
if (time_after_eq(jiffies, base->next_expiry)) {
raise_softirq(TIMER_SOFTIRQ);
return;
}
}
raise_softirq(TIMER_SOFTIRQ);
}

/*
Expand Down

0 comments on commit af68cb3

Please sign in to comment.