Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp904416rdb; Fri, 1 Dec 2023 01:27:54 -0800 (PST) X-Google-Smtp-Source: AGHT+IEeZDVwiWz75+zNCjJpjghsaVpUxgGg4iAugW+pfxts9lJ425hxEsYmL5DMTKZKw8cHCNTS X-Received: by 2002:a05:6358:178c:b0:170:94d:24d1 with SMTP id y12-20020a056358178c00b00170094d24d1mr2222497rwm.24.1701422874069; Fri, 01 Dec 2023 01:27:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422874; cv=none; d=google.com; s=arc-20160816; b=Wwr1qNrktIZPU5DP1QJwoE6qLay6XdLvGvurMIoEGJcpS33mkpc5Fir8NUnWs3hh8d 0kDwR/BALpdO8Xw1mg4bvblrqPwut5PCPmrwwfG9rAccGpxD8l/UsDtuhtR8J2uZkfh+ 3HjU3APmU1m3uZ55xHn/NLPZCmxF6n4UFVhCZWXVtezs1rK25TfpWdLhT0cVVi0czwIQ f18Y+Vklq3mWk5bCXB14QPIEyBNpnC4C9Zb5xym+sQ0xgZ9IGP1aqNlyONWxx0EoXMRR zLrL/gbwfoprIrIofr1B58/Eh4RHAkNJygHQRC+by2tBoLiiUCw8a8kIxvZ7AiFoIGue Fvug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=gO/udsWQ+bQJ+e/QIsLEl2DMKpANRb9evAUW1EC/BoI=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=md5vDEGGztCUMpcv+zMch6v9AgWVTxaMaKKniXJ8HtjYMoeWffniCEOmMJJJr763uN cnwyF1yWkm0wtn2i4zRCwmEtuALUQpdut/8E2HBlSkv3kE5nMrTQ27DSMm1ZwUKGDBJT BDpF+e9B3p2mJbCWC36cEPDkC+8KCiWwawqQ3TVxxYXannilO0s2RSy4i/AONOHIIoC+ zE2SqBWGXnojmkkB2pxxwaTNJ86qv8GZgyb6qi648v170yEdI3P7NOukzRnTia7qUJUh wDCFmWEzrjbUDL6c62JZK+vONerrrJTZFwjPfWsr1PfoVeTMBuB4Ck5AjV9MGaEsvjCD KrAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="eIQqB/WQ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DLkvoQ1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id a30-20020a056a001d1e00b006cbfbb70262si2994625pfx.318.2023.12.01.01.27.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:27:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="eIQqB/WQ"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=DLkvoQ1h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 024F1810FBC3; Fri, 1 Dec 2023 01:27:48 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378066AbjLAJ10 (ORCPT + 99 others); Fri, 1 Dec 2023 04:27:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49080 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378034AbjLAJ1G (ORCPT ); Fri, 1 Dec 2023 04:27:06 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 092D610F9 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=1701422831; 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=gO/udsWQ+bQJ+e/QIsLEl2DMKpANRb9evAUW1EC/BoI=; b=eIQqB/WQldigQLY0Gair11m9tMLsVtE1Ib3/oPytcBEd0/qDyfDCkRvTegLi/ZOrzT7FAp m6oEWHBnwrgAMkh9+bzPfsxav1MuLLAhzI9oyKAjTVdcqH2yPJXlWIy6lJF+SCwvcwKr1X 7Pp+MFb8jhvlCfqGjEwPSRKuAt9kEkCnabNBehpLjPbkXIZ8K5IoNUljS6/u50/eSfQgUf VSThVmxWrJu8mpM5Qi5/FgIUXg+bYlY8yit7NI2v3s5jB8u5yF0EAH4bk1q8dEM325dil4 5dNv4T2hfHZdbg62aF0lh9ESjOV1r6Dbv991Z5BpJBgmgLhuWM8DC8/sKkvU4g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422831; 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=gO/udsWQ+bQJ+e/QIsLEl2DMKpANRb9evAUW1EC/BoI=; b=DLkvoQ1hQ176JTziAZ/kfHhh7nRRJW7GCXqvS2BDCpVLtS0WNM3KRr3h6ZYLXNylsajT5P e48W33DVK1JYzuDw== 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 08/32] timers: Clarify check in forward_timer_base() Date: Fri, 1 Dec 2023 10:26:30 +0100 Message-Id: <20231201092654.34614-9-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: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 01 Dec 2023 01:27:48 -0800 (PST) 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(). Move the precious information of the outdated comment to the proper place in __run_timers(). No functional change. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Frederic Weisbecker --- v9: Move precious information of outdated comment to proper place (as suggested by Frederic) --- kernel/time/timer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 3ca706db1d20..66bac56909ba 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -944,11 +944,10 @@ static inline void forward_timer_base(struct timer_base *base) unsigned long jnow = READ_ONCE(jiffies); /* - * 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; /* @@ -2015,6 +2014,10 @@ static inline void __run_timers(struct timer_base *base) */ WARN_ON_ONCE(!levels && !base->next_expiry_recalc && base->timers_pending); + /* + * While executing timers, base->clk is set 1 offset ahead of + * jiffies to avoid endless requeuing to current jiffies. + */ base->clk++; next_expiry_recalc(base); -- 2.39.2