From patchwork Wed Oct 4 12:34:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 148258 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98459vqb; Wed, 4 Oct 2023 05:36:31 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/Z6qJF89M5Po4Ja/amhdKy4wxKKbXhtIpwswO2VA7XIVc4zAjuAo76WjQB9a+AlKCcDpi X-Received: by 2002:a17:902:c449:b0:1c5:a09e:170a with SMTP id m9-20020a170902c44900b001c5a09e170amr1785488plm.54.1696422991531; Wed, 04 Oct 2023 05:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696422991; cv=none; d=google.com; s=arc-20160816; b=o4ZVMKyWvXrMtjX1qoz6kt8eCtzhQedpS9y6bBw7QIC9QW09WRa/oB0O1Nki2s55ce uVRt+VfScnkh00iUOUK3G2Q63f8kppOAoPHcFKqbubLE12chVUsOnA3wnwLewVrHz0vx qtgjT6AGNp7NcFsVGUkH0JU6f6NxxN5AkjWolLQgGjZJjegb4Js25A2E36GVahKvGVtW q03G/o0Pjcbt3pEIvPanoZp3MJ2Qa6AQdCUDehxTtIW1iiGIDRD0CtQGErC7krlPCnnK fOXHxFCo5jrLJMiMK2CvuIfxV5mJQAD4GdsFpGuREYA/q2/e7h13LJdDTXeaSe/MulRo 2AmQ== 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=fTra8o64I3zbTAJb74gQJVLr6rBx5QpDSUDk/VGWLOU=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=k3RwC/IVgJkkhaaWtSpsxlNq+kjL8l7IIIWjZ5acYxWITCH8rpabdyhur9kFN+WZRa 4Z4pjPHnIzv3TUbU2W5MDIDJQNL3OVx/laxyACqc/30h0Rw6M3T1mKirqj6RehFFY5GV ajpNYg2eLca9o8p1gTBelCld1ZrQLmpJi2vK638pyT1h8VUEgGeyyfbWso76obrHBmsc 8wIcxEAL7K1OKQOi1m4FlBDlDurM7pgmxJlaD8U0qLHNxsclVzsPvrGgVrhEFpNnOfQT npxYnexVw8BmWCtf9vzPDkzwSBvJhx/+4cQ2x+HyhsVyHroG62Iad6NukUPUlsR42+73 RBTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="sA0UW/pv"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rPMWo+lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id c7-20020a170902d48700b001c741de8529si3839465plg.380.2023.10.04.05.36.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="sA0UW/pv"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=rPMWo+lO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 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 snail.vger.email (Postfix) with ESMTP id E8C728031C47; Wed, 4 Oct 2023 05:35:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242427AbjJDMfp (ORCPT + 18 others); Wed, 4 Oct 2023 08:35:45 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 (snail.vger.email [0.0.0.0]); Wed, 04 Oct 2023 05:35:51 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828434784424749 X-GMAIL-MSGID: 1778828434784424749 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_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; /*