lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231004123454.15691-19-anna-maria@linutronix.de>
Date:   Wed,  4 Oct 2023 14:34:47 +0200
From:   Anna-Maria Behnsen <anna-maria@...utronix.de>
To:     linux-kernel@...r.kernel.org
Cc:     Peter Zijlstra <peterz@...radead.org>,
        John Stultz <jstultz@...gle.com>,
        Thomas Gleixner <tglx@...utronix.de>,
        Eric Dumazet <edumazet@...gle.com>,
        "Rafael J . Wysocki" <rafael.j.wysocki@...el.com>,
        Arjan van de Ven <arjan@...radead.org>,
        "Paul E . McKenney" <paulmck@...nel.org>,
        Frederic Weisbecker <frederic@...nel.org>,
        Rik van Riel <riel@...riel.com>,
        Steven Rostedt <rostedt@...dmis.org>,
        Sebastian Siewior <bigeasy@...utronix.de>,
        Giovanni Gherdovich <ggherdovich@...e.cz>,
        Lukasz Luba <lukasz.luba@....com>,
        "Gautham R . Shenoy" <gautham.shenoy@....com>,
        Srinivas Pandruvada <srinivas.pandruvada@...el.com>,
        K Prateek Nayak <kprateek.nayak@....com>,
        Anna-Maria Behnsen <anna-maria@...utronix.de>
Subject: [PATCH v8 18/25] timer: Split out "get next timer interrupt" functionality

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@...utronix.de>
Reviewed-by: Frederic Weisbecker <frederic@...nel.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(-)

diff --git a/kernel/time/timer.c b/kernel/time/timer.c
index 4230fc6fa1ed..c3061b28214e 100644
--- a/kernel/time/timer.c
+++ b/kernel/time/timer.c
@@ -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;
 }
 
-- 
2.39.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ