The functionality for getting the next timer interrupt in
get_next_timer_interrupt() is split into a separate function
fetch_next_timer_interrupt() to be usable by other call sites.
This is preparatory work for the conversion of the NOHZ timer
placement to a pull at expiry time model. No functional change.
Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
---
v6: s/splitted/split
v5: Update commit message
v4: Fix typo in comment
---
kernel/time/timer.c | 51 +++++++++++++++++++++++++++------------------
1 file changed, 31 insertions(+), 20 deletions(-)
@@ -1976,12 +1976,12 @@ static unsigned long next_timer_interrupt(struct timer_base *base)
return base->next_expiry;
}
-static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 basem,
- struct timer_base *base_local,
- struct timer_base *base_global,
- struct timer_events *tevt)
+static unsigned long fetch_next_timer_interrupt(unsigned long basej, u64 basem,
+ struct timer_base *base_local,
+ struct timer_base *base_global,
+ struct timer_events *tevt)
{
- unsigned long nextevt, nextevt_local, nextevt_global;
+ unsigned long nextevt_local, nextevt_global;
bool local_first;
nextevt_local = next_timer_interrupt(base_local);
@@ -2000,21 +2000,6 @@ static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64
else
local_first = base_local->timers_pending;
- nextevt = local_first ? nextevt_local : nextevt_global;
-
- /*
- * If the @nextevt is at max. one tick away, use @nextevt and store
- * it in the local expiry value. The next global event is irrelevant in
- * this case and can be left as KTIME_MAX.
- */
- if (time_before_eq(nextevt, basej + 1)) {
- /* If we missed a tick already, force 0 delta */
- if (time_before(nextevt, basej))
- nextevt = basej;
- tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC;
- return tevt->local;
- }
-
/*
* Update tevt->* values:
*
@@ -2028,6 +2013,32 @@ static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64
if (base_local->timers_pending)
tevt->local = basem + (u64)(nextevt_local - basej) * TICK_NSEC;
+ return local_first ? nextevt_local : nextevt_global;
+}
+
+static inline unsigned long __get_next_timer_interrupt(unsigned long basej, u64 basem,
+ struct timer_base *base_local,
+ struct timer_base *base_global,
+ struct timer_events *tevt)
+{
+ unsigned long nextevt;
+
+ nextevt = fetch_next_timer_interrupt(basej, basem,
+ base_local, base_global, tevt);
+
+ /*
+ * If the nextevt is at max. one tick away, use the @nextevt and store
+ * it in the local expiry value. Reset of next global event to KTIME_MAX
+ * to make sure it is ignored.
+ */
+ if (time_before_eq(nextevt, basej + 1)) {
+ /* If we missed a tick already, force 0 delta */
+ if (time_before(nextevt, basej))
+ nextevt = basej;
+ tevt->local = basem + (u64)(nextevt - basej) * TICK_NSEC;
+ tevt->global = KTIME_MAX;
+ }
+
return nextevt;
}