Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp904347rdb; Fri, 1 Dec 2023 01:27:46 -0800 (PST) X-Google-Smtp-Source: AGHT+IGKNSE2mE7LkZ0JolLWlXxLcx4d8uzAnGwLOqCss/MPnFP6vCPe8F3c9Dsmp5+ZWEbLW0bL X-Received: by 2002:a05:6a20:d04d:b0:189:fd93:c969 with SMTP id hv13-20020a056a20d04d00b00189fd93c969mr32253108pzb.26.1701422865900; Fri, 01 Dec 2023 01:27:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701422865; cv=none; d=google.com; s=arc-20160816; b=u4QE3M+1Hebl/DceACRsIAT283VP8n26xAKNHOue53sOLcWsigRB5mpK1nxC0Zud2u dPHz7YB0intiNeb8TJmruHIIwk6pstpLso2h+koVCDMmrKS7p4SSE93Ljd5pyv4+c6oT AnwMKwjLpeN6dMlYZccYeP/X+9FD85cp5tSn2gcENDanEeMatJZu+5yCx9jBtXpWSwaB mi7ToJ6Lbb1OjKIv1op5Zok0sWcbf1zt3UGAyiNFJZyXOBo3A37NW9bmiTFkCJPI1qzN Qo8rAfMsRfPzcAcy7zwdpzvnDSHdcfxTJeT5kcS48xKZASSdyinWihm18ZOX3RPEIvrC sblw== 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=NX2OtYZi8wYLdH4/EBEFqndbEahIgfLRJkHvTArpnf8=; fh=PG6uS4TiiUSDyl8D/joYkWbwCgDm4ug0ir2h7tHBJXQ=; b=qlWYumZfGv/ejheOIATJVXcbmVHt3h/1/hUUeE9C54YrEbn7ezzpNU32t4SFqV4T3n 9+DoB8ntaKPADtNDhEklGBLqZXBZeOxHAd6OtiYBBbGjKEwUdkIs9Kco7yMr5Fjr+tT2 RxZJiv36BW6AkDpXTcQNpUIpb66sou5r3u94nFu8muM9UuTCoChj8+gLrig5WP7NTRWE Q83leN+9W09AWFM3uCEu25p13RA8i8DYAt9hS0uURw/u86UPOjCdx90ggfI7Qx+KSaTA voXwGX1t8l6IP9mvXxDgiXwuvSCaCxlm/u7ajjPv8HSh4cZ3oKWAOIFMKIl3NfdJ+fK0 TB/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1ggAH7wj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="FWFW6/pn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id e29-20020a63501d000000b005c5e2118e11si3029209pgb.70.2023.12.01.01.27.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 01:27:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1ggAH7wj; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="FWFW6/pn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 9A0AF80ECF34; Fri, 1 Dec 2023 01:27:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378099AbjLAJ1d (ORCPT + 99 others); Fri, 1 Dec 2023 04:27:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49106 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378035AbjLAJ1H (ORCPT ); Fri, 1 Dec 2023 04:27:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB89710FC 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=1701422832; 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=NX2OtYZi8wYLdH4/EBEFqndbEahIgfLRJkHvTArpnf8=; b=1ggAH7wj+axl9TgEGJFZ0/uAb3cs+EW+X/QNAiGkGxhubO1WQ+ye67f57geO0uUgLmkZkL HvIPqcMu+1kgF6qnb72qlUj9+XGiJQS0qO4JNx9UYCX5iEGrK9FyAavNTYTSNwNpE9ghjY AfDEUuun8UgRzUrq7qEydbw/pXjJWUdOCUkmVDsiEWDsuPTYlj3u1B6Lr6HDIQzL2LG76+ kQcf4y/R6aiDYIlAQdaPPdghBaLiASdU2NCpEJEfA9zsdj9Hf9ZpuCbdej0w3aUOfxFDWQ ZNCAwSvoyAy9aMCi13puWX28GeFSL9rfPfL9btfjxsrP8FzpUmD8JWwSRMXaOQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1701422832; 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=NX2OtYZi8wYLdH4/EBEFqndbEahIgfLRJkHvTArpnf8=; b=FWFW6/pnQLncFa4pPnDKR90jyaAVnwrvB+ARbjuC6CzkQWAsi8kK9Gc2XmjQxcA0arZv6p oCcqOjNaJyyrPcDg== 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 09/32] timers: Split out forward timer base functionality Date: Fri, 1 Dec 2023 10:26:31 +0100 Message-Id: <20231201092654.34614-10-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=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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]); Fri, 01 Dec 2023 01:27:44 -0800 (PST) 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 66bac56909ba..e289cbd84e8c 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -939,30 +939,34 @@ get_target_base(struct timer_base *base, unsigned tflags) return get_timer_this_cpu_base(tflags); } -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 = 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; /* * 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 = jnow; + if (time_after(base->next_expiry, basej)) { + base->clk = basej; } else { if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) return; base->clk = base->next_expiry; } + } +static inline void forward_timer_base(struct timer_base *base) +{ + __forward_timer_base(base, READ_ONCE(jiffies)); +} /* * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means -- 2.39.2