From nobody Tue Feb 10 17:07:55 2026 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 07EA9C77B7A for ; Wed, 24 May 2023 07:07:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239931AbjEXHHu (ORCPT ); Wed, 24 May 2023 03:07:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239838AbjEXHHH (ORCPT ); Wed, 24 May 2023 03:07:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B41819C for ; Wed, 24 May 2023 00:07:03 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912021; 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=69v6KAzJ3Kkk+I5jf4FnTJ5YhbczmyAfH/JLKYuJ49U=; b=WML/DefTybhtSenrVmJjckwFy5HhArUrPp5NzIJCOlVIS+tsDYpGGz6XtAL/Tjej+iS+eX rNbbfqXomGylr1TyXGNF9C7oSeCfGOkYaCL6sd1BAOaFGieZNgZw+gx3W72RrGrsEqcGLc j41YELXuAC9lwkibcnANeJAr2yPbqNP9bpeigvcmY9yC12BVpQNQFx7PrtdJqmvtPCaA9q yZUPwZjmnH+97vj8H5kp0G1Ce7qmOae3ftU+CRjdlMHVs2P6sddNhWkRxPuKSsTu5Dd7cM UGNTTHsaFHXiDV0x82Y1FRDIPj9ryBiaIHna/DBFGClomSc/MPfLR+bRKzgpFA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912021; 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=69v6KAzJ3Kkk+I5jf4FnTJ5YhbczmyAfH/JLKYuJ49U=; b=c1N1GlFettzOJ4SoyCIpwPS+BzrT4zoXcaFKud66e1Fyr8PpCx/7gD+aeuKM8PYcvWUASH RMvesJu/2iq35MAA== 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" , Anna-Maria Behnsen , Frederic Weisbecker Subject: [PATCH v7 11/21] timers: Create helper function to forward timer base clk Date: Wed, 24 May 2023 09:06:19 +0200 Message-Id: <20230524070629.6377-12-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-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 logic for forwarding timer base clock is split into a separate function to make it accessible for other call sites. No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v6: s/splitted/split v5: New patch to simplify next patch --- kernel/time/timer.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 749b1570bdcd..fcff03757641 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -1956,6 +1956,21 @@ static unsigned long next_timer_interrupt(struct tim= er_base *base) return base->next_expiry; } =20 +/* + * Forward base clock is done only when @basej is past base->clk, otherwise + * base-clk might be rewind. + */ +static void forward_base_clk(struct timer_base *base, unsigned long nextev= t, + unsigned long basej) +{ + if (time_after(basej, base->clk)) { + if (time_after(nextevt, basej)) + base->clk =3D basej; + else if (time_after(nextevt, base->clk)) + base->clk =3D nextevt; + } +} + /** * get_next_timer_interrupt - return the time (clock mono) of the next tim= er * @basej: base time jiffies @@ -1987,15 +2002,9 @@ u64 get_next_timer_interrupt(unsigned long basej, u6= 4 basem) =20 /* * We have a fresh next event. Check whether we can forward the - * base. We can only do that when @basej is past base->clk - * otherwise we might rewind base->clk. + * base. */ - if (time_after(basej, base->clk)) { - if (time_after(nextevt, basej)) - base->clk =3D basej; - else if (time_after(nextevt, base->clk)) - base->clk =3D nextevt; - } + forward_base_clk(base, nextevt, basej); =20 /* * Base is idle if the next event is more than a tick away. Also --=20 2.30.2