[v3,04/17] timer: Split next timer interrupt logic

Message ID 20221025135850.51044-5-anna-maria@linutronix.de
State New
Headers
Series timer: Move from a push remote at enqueue to a pull at expiry model |

Commit Message

Anna-Maria Behnsen Oct. 25, 2022, 1:58 p.m. UTC
  Logic for getting next timer interrupt (no matter of recalculated or
already stored in base->next_expiry) is split into a separate function
"next_timer_interrupt()" to make it available for new call sites.

No functional change.

Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/time/timer.c | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)
  

Comments

Frederic Weisbecker Oct. 26, 2022, 9:40 a.m. UTC | #1
On Tue, Oct 25, 2022 at 03:58:37PM +0200, Anna-Maria Behnsen wrote:
> Logic for getting next timer interrupt (no matter of recalculated or
> already stored in base->next_expiry) is split into a separate function
> "next_timer_interrupt()" to make it available for new call sites.
> 
> No functional change.
> 
> Signed-off-by: Anna-Maria Behnsen <anna-maria@linutronix.de>
> Reviewed-by: Thomas Gleixner <tglx@linutronix.de>

Reviewed-by: Frederic Weisbecker <frederic@kernel.org>
  

Patch

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 7695c733dfa5..f34bc75ff848 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -1681,6 +1681,15 @@  static u64 cmp_next_hrtimer_event(u64 basem, u64 expires)
 	return DIV_ROUND_UP_ULL(nextevt, TICK_NSEC) * TICK_NSEC;
 }
 
+
+static unsigned long next_timer_interrupt(struct timer_base *base)
+{
+	if (base->next_expiry_recalc)
+		__next_timer_interrupt(base);
+
+	return base->next_expiry;
+}
+
 /**
  * get_next_timer_interrupt - return the time (clock mono) of the next timer
  * @basej:	base time jiffies
@@ -1703,9 +1712,8 @@  u64 get_next_timer_interrupt(unsigned long basej, u64 basem)
 		return expires;
 
 	raw_spin_lock(&base->lock);
-	if (base->next_expiry_recalc)
-		__next_timer_interrupt(base);
-	nextevt = base->next_expiry;
+
+	nextevt = next_timer_interrupt(base);
 
 	/*
 	 * We have a fresh next event. Check whether we can forward the