From nobody Wed Sep 10 02:01:41 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 258D9E7B601 for ; Wed, 4 Oct 2023 12:35:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242437AbjJDMft (ORCPT ); Wed, 4 Oct 2023 08:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242362AbjJDMfd (ORCPT ); Wed, 4 Oct 2023 08:35:33 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A438193 for ; Wed, 4 Oct 2023 05:35:30 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422929; 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=W54m7rvqf/KqCMpTV79oOtmZr9LItvdWHEN45lcUeaw=; b=Efrc1xoorJOzy8tsALP1Bhr1M7Nxl+bJb/TLuAn1JJNB+EXwQE2BEjWHaW9r482myE0wWL uyLPSjVJw/V3m5a2xAAfe0w7iX/ytMsCbLv2tlTECGXATITJthK/1y6An9HyHv+7ky8UNx fnHJSOY2T7+agSXCrPYFIOj9ItFLcUo0G7iR/mN98qfQSUB2Ws3EteNzW/outR2GYMFdcx ZFt0ZjSVe6aKa5SGx5o1vMRv+CpHEF2kFZa1OL6kuHQgkcL0dIRC0Sc9kL61V9WnqSZppx f6yrhTvO2oWkhTA1l9pdm8ybiwUDZcfyp9uv9BD0L4FC9nMTEMZCKyY5jcB3Pw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422929; 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=W54m7rvqf/KqCMpTV79oOtmZr9LItvdWHEN45lcUeaw=; b=HnIgZMU7Y2g9X5WBxvEHh86H4zJMqVCS4RU8TGz0WgX52KTUJ1COlkvacxUBh/tihoDYYG 6WDL1TBNzELczOCg== 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 06/25] timers: Split out forward timer base functionality Date: Wed, 4 Oct 2023 14:34:35 +0200 Message-Id: <20231004123454.15691-7-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" 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 31aed8353db1..2f6afd1da891 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