From nobody Wed Sep 10 02:01:36 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B16E7B604 for ; Wed, 4 Oct 2023 12:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242546AbjJDMgY (ORCPT ); Wed, 4 Oct 2023 08:36:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242419AbjJDMfp (ORCPT ); Wed, 4 Oct 2023 08:35:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A73EE106 for ; Wed, 4 Oct 2023 05:35:37 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PYE4qjcpMvpvRPLtFGjkbKuz071Vlys4ffOshPkJzPM=; b=zB4VvhF4vv/KNyy86ETm1uDqt4dNpl+dbiQYCpi/lMo7g23qLXbl+5zA2C1beMPiSDCANe 2D7HoBlrCPy0eMmmdBOVpyOiL2ZeB7DTpwGfE21dRqWZ4mtVuYXFlDzfl97wIDSsxTq5pX nUuX7qltUVYUlnelarpkoRqdX4r28jCSXB31y9GZPIV4nDXa8UAhl6yqbUhcL8UqX7lt3r Wnhj7QLc1fPVzZy/gWASE1JaclowXo6p0LJVMKeYWsvIqMjAjqHt8RUz0f4fyHAdnqkllW 6CMPygGZH8/cgCN3AnmoDC6mChROdKVMkFoSmb2NZGy5lmipXlts3+mw0yHbIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422936; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PYE4qjcpMvpvRPLtFGjkbKuz071Vlys4ffOshPkJzPM=; b=gc7NqSHIVqrsBUySm1W+IZ8NZ7pgDH+rnNSRCK+1NYOTkHPp0LqWHr7uGCFD1W1iynhq1+ zgk4tZDZXYsdnTDw== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Thomas Gleixner , Eric Dumazet , "Rafael J . Wysocki" , Arjan van de Ven , "Paul E . McKenney" , Frederic Weisbecker , Rik van Riel , Steven Rostedt , Sebastian Siewior , Giovanni Gherdovich , Lukasz Luba , "Gautham R . Shenoy" , Srinivas Pandruvada , K Prateek Nayak , Anna-Maria Behnsen Subject: [PATCH v8 18/25] timer: Split out "get next timer interrupt" functionality Date: Wed, 4 Oct 2023 14:34:47 +0200 Message-Id: <20231004123454.15691-19-anna-maria@linutronix.de> In-Reply-To: <20231004123454.15691-1-anna-maria@linutronix.de> References: <20231004123454.15691-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Frederic Weisbecker --- 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 ti= mer_base *base) return base->next_expiry; } =20 -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 b= asem, + 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; =20 nextevt_local =3D next_timer_interrupt(base_local); @@ -2000,21 +2000,6 @@ static inline unsigned long __get_next_timer_interru= pt(unsigned long basej, u64 else local_first =3D base_local->timers_pending; =20 - nextevt =3D 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 =3D basej; - tevt->local =3D basem + (u64)(nextevt - basej) * TICK_NSEC; - return tevt->local; - } - /* * Update tevt->* values: * @@ -2028,6 +2013,32 @@ static inline unsigned long __get_next_timer_interru= pt(unsigned long basej, u64 if (base_local->timers_pending) tevt->local =3D basem + (u64)(nextevt_local - basej) * TICK_NSEC; =20 + 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 =3D 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 =3D basej; + tevt->local =3D basem + (u64)(nextevt - basej) * TICK_NSEC; + tevt->global =3D KTIME_MAX; + } + return nextevt; } =20 --=20 2.39.2