From nobody Mon Dec 29 05:04:22 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 C7309C10F04 for ; Fri, 1 Dec 2023 09:27:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378101AbjLAJ1e (ORCPT ); Fri, 1 Dec 2023 04:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378035AbjLAJ1H (ORCPT ); Fri, 1 Dec 2023 04:27:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB89710FC for ; Fri, 1 Dec 2023 01:27:13 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1701422832; 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=NX2OtYZi8wYLdH4/EBEFqndbEahIgfLRJkHvTArpnf8=; b=1ggAH7wj+axl9TgEGJFZ0/uAb3cs+EW+X/QNAiGkGxhubO1WQ+ye67f57geO0uUgLmkZkL HvIPqcMu+1kgF6qnb72qlUj9+XGiJQS0qO4JNx9UYCX5iEGrK9FyAavNTYTSNwNpE9ghjY AfDEUuun8UgRzUrq7qEydbw/pXjJWUdOCUkmVDsiEWDsuPTYlj3u1B6Lr6HDIQzL2LG76+ kQcf4y/R6aiDYIlAQdaPPdghBaLiASdU2NCpEJEfA9zsdj9Hf9ZpuCbdej0w3aUOfxFDWQ ZNCAwSvoyAy9aMCi13puWX28GeFSL9rfPfL9btfjxsrP8FzpUmD8JWwSRMXaOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422832; 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=NX2OtYZi8wYLdH4/EBEFqndbEahIgfLRJkHvTArpnf8=; b=FWFW6/pnQLncFa4pPnDKR90jyaAVnwrvB+ARbjuC6CzkQWAsi8kK9Gc2XmjQxcA0arZv6p oCcqOjNaJyyrPcDg== 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 v9 09/32] timers: Split out forward timer base functionality Date: Fri, 1 Dec 2023 10:26:31 +0100 Message-Id: <20231201092654.34614-10-anna-maria@linutronix.de> In-Reply-To: <20231201092654.34614-1-anna-maria@linutronix.de> References: <20231201092654.34614-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" Forwarding timer base is done when the next expiry value is calculated and when a new timer is enqueued. When the next expiry value is calculated the jiffies value is already available and does not need to be reread a second time. Splitting out the forward timer base functionality to make it executable via both contextes - those where jiffies are already known and those, where jiffies need to be read. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 66bac56909ba..e289cbd84e8c 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -939,30 +939,34 @@ get_target_base(struct timer_base *base, unsigned tfl= ags) return get_timer_this_cpu_base(tflags); } =20 -static inline void forward_timer_base(struct timer_base *base) +static inline void __forward_timer_base(struct timer_base *base, + unsigned long basej) { - unsigned long jnow =3D READ_ONCE(jiffies); - /* * Check whether we can forward the base. We can only do that when * @basej is past base->clk otherwise we might rewind base->clk. */ - if (time_before_eq(jnow, base->clk)) + if (time_before_eq(basej, base->clk)) return; =20 /* * If the next expiry value is > jiffies, then we fast forward to * jiffies otherwise we forward to the next expiry value. */ - if (time_after(base->next_expiry, jnow)) { - base->clk =3D jnow; + if (time_after(base->next_expiry, basej)) { + base->clk =3D basej; } else { if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) return; base->clk =3D base->next_expiry; } + } =20 +static inline void forward_timer_base(struct timer_base *base) +{ + __forward_timer_base(base, READ_ONCE(jiffies)); +} =20 /* * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means --=20 2.39.2