From nobody Wed Sep 10 02:01:38 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 03450E7B604 for ; Wed, 4 Oct 2023 12:35:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242436AbjJDMfq (ORCPT ); Wed, 4 Oct 2023 08:35:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233099AbjJDMfd (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 1AF98A9 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=1696422928; 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=fTra8o64I3zbTAJb74gQJVLr6rBx5QpDSUDk/VGWLOU=; b=sA0UW/pvV/0I55AunJMU0m83CMjHJk5r5kdLxlyfE5RHs6n2hfsQX33oRxvi9/LC/hLyyf acAxxQ3LRzUlbNQApBnpa9BDd6PU0ElLSc88hLv0grsakqDGORuuYTfl5ytsnTF/bMcT+g LsWtmKJB8Z932SK3BDWZQXgpBIvlwm3vnS6oVRM18V+RDQzbyOV5I8+v9wg8dSCRrX6sZb CX3TGzAQNFADyBimYEDHtOmCjkjKt1NZMvyELWh8/IlYe9CSvymheg5VuMVYjyh/h3+nzS qwmncbE0c2RxFcLJ4fwM4jVwBwhPUiKpz4odW2lj6e1xqfYajr6buP+Ip0gpMw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422928; 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=fTra8o64I3zbTAJb74gQJVLr6rBx5QpDSUDk/VGWLOU=; b=rPMWo+lOy4PE80VFeDYCp2Y6PFaJPY1u8tmVAKOXxSKx1uhqwSb5Gl87jgPVYAz7ibOnqC WpV+cYoGPUx5t9Bw== 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 05/25] timers: Clarify check in forward_timer_base() Date: Wed, 4 Oct 2023 14:34:34 +0200 Message-Id: <20231004123454.15691-6-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 current check whether a forward of the timer base is required can be simplified by using an already existing comparison function which is easier to read. The related comment is outdated and was not updated when the check changed in commit 36cd28a4cdd0 ("timers: Lower base clock forwarding threshold"). Use time_before_eq() for the check and replace the comment by copying the comment from the same check inside get_next_timer_interrupt(). No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- kernel/time/timer.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 5e17244a9465..31aed8353db1 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -944,11 +944,10 @@ static inline void forward_timer_base(struct timer_ba= se *base) unsigned long jnow =3D READ_ONCE(jiffies); =20 /* - * No need to forward if we are close enough below jiffies. - * Also while executing timers, base->clk is 1 offset ahead - * of jiffies to avoid endless requeuing to current 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 ((long)(jnow - base->clk) < 1) + if (time_before_eq(jnow, base->clk)) return; =20 /* --=20 2.39.2