Skip to content

Commit 9f6a3c6

Browse files
anna-marialxKAGA-KOKO
authored andcommitted
timers: Split next timer interrupt logic
Split the logic for getting next timer interrupt (no matter of recalculated or already stored in base->next_expiry) into a separate function named next_timer_interrupt(). Make it available to local call sites only. 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-10-anna-maria@linutronix.de
1 parent af68cb3 commit 9f6a3c6

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

kernel/time/timer.c

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,12 +1996,29 @@ static u64 cmp_next_hrtimer_event(u64 basem, u64 expires)
19961996
return DIV_ROUND_UP_ULL(nextevt, TICK_NSEC) * TICK_NSEC;
19971997
}
19981998

1999+
static unsigned long next_timer_interrupt(struct timer_base *base,
2000+
unsigned long basej)
2001+
{
2002+
if (base->next_expiry_recalc)
2003+
next_expiry_recalc(base);
2004+
2005+
/*
2006+
* Move next_expiry for the empty base into the future to prevent an
2007+
* unnecessary raise of the timer softirq when the next_expiry value
2008+
* will be reached even if there is no timer pending.
2009+
*/
2010+
if (!base->timers_pending)
2011+
base->next_expiry = basej + NEXT_TIMER_MAX_DELTA;
2012+
2013+
return base->next_expiry;
2014+
}
2015+
19992016
static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem,
20002017
bool *idle)
20012018
{
20022019
struct timer_base *base = this_cpu_ptr(&timer_bases[BASE_STD]);
2003-
unsigned long nextevt = basej + NEXT_TIMER_MAX_DELTA;
20042020
u64 expires = KTIME_MAX;
2021+
unsigned long nextevt;
20052022

20062023
/*
20072024
* Pretend that there is no timer pending if the cpu is offline.
@@ -2014,24 +2031,13 @@ static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem,
20142031
}
20152032

20162033
raw_spin_lock(&base->lock);
2017-
if (base->next_expiry_recalc)
2018-
next_expiry_recalc(base);
2034+
nextevt = next_timer_interrupt(base, basej);
20192035

20202036
if (base->timers_pending) {
2021-
nextevt = base->next_expiry;
2022-
20232037
/* If we missed a tick already, force 0 delta */
20242038
if (time_before(nextevt, basej))
20252039
nextevt = basej;
20262040
expires = basem + (u64)(nextevt - basej) * TICK_NSEC;
2027-
} else {
2028-
/*
2029-
* Move next_expiry for the empty base into the future to
2030-
* prevent a unnecessary raise of the timer softirq when the
2031-
* next_expiry value will be reached even if there is no timer
2032-
* pending.
2033-
*/
2034-
base->next_expiry = nextevt;
20352041
}
20362042

20372043
/*

0 commit comments

Comments
 (0)