From patchwork Wed Oct 4 12:34:51 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: 148268 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:254a:b0:403:3b70:6f57 with SMTP id hf10csp98725vqb; Wed, 4 Oct 2023 05:36:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHk8As0BxB0Z76iqfAGdio3anKa8VCJBlxXEQw5ytaJttcpGLDD5+7xOhQj7YsTr44zvs2N X-Received: by 2002:a17:902:d2c2:b0:1c7:3526:dfcd with SMTP id n2-20020a170902d2c200b001c73526dfcdmr2056205plc.52.1696423008059; Wed, 04 Oct 2023 05:36:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696423008; cv=none; d=google.com; s=arc-20160816; b=EWF6X+7ftU2qbaYBQ0Zk2EJWnP0X2Ha08r1icr9MgUeN1ykRScPMtzSiYvbce4n5dG Xw9ShME8FpqIOr/NhF+n5qGh1KQ/QNgcCEJ9u0M4imd7sMkuWUe7RjkMK4qot7kqO0sM PYAU/q5pl3hpIlNttBRRIliomy3YC8/gxyF8wjCCk8Padjpm5J3K64RI3D5FMn3dmVql nSx0oOXKnq5SRHc8K1ijj5l9PmVXKSHBc55wHi9AgMRNbfTmTDd0GDQ9hHhDhWhgso1d D1N9Q7fwVHLIr8aR9z1kwyudRpU4LHHpBSYibDr1piO47GJ9tq/X0WeSmSi8Hml6jTk9 qWbw== 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=ch0dJixaaY+pPoIMtZ/2D1P4Dl6dWsbaFTlXDeDmHfo=; fh=H6hHKnScvHhKAB7z8Wb75LBNJxB0aNyPhv3ZCgyEYhY=; b=ZG2eFNHABdYTVcMOaUv5PMxAJhz4oLABzfFDsB7DkuJBqqQho1fLcliH+6IaP0m4bP yZUbCZ7aQvbF/nbQJ/I/P1ghMkz81yMcypcn9+gCwt2rODHZKv3qNpgnSqjQWQqh7DKD Pe98oEG5TQ+nYbhzkoRX1l7rfETqPpqgjtQikl/LJb/a5duVzsw3ICnnxB/egonYoIEh 2Z6DJBIouKI0Zif3F1bZGp2PGrhdUl51oF4oUmayIoyw3jW4ZtCedNQRBqBNX51C+am2 WvzIFeu6s22wEfTP6fiFwcsXNrPjAcaEEuIJl1zwel40jnqEv6NoDh4QD6xwZQNiRZH/ xEyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=EWEnazDZ; dkim=neutral (no key) header.i=@linutronix.de; 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 p14-20020a170902e74e00b001c62d7e4831si4027145plf.588.2023.10.04.05.36.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 05:36:48 -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=EWEnazDZ; dkim=neutral (no key) header.i=@linutronix.de; 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 A676482159FF; Wed, 4 Oct 2023 05:36:17 -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 S242492AbjJDMgO (ORCPT + 18 others); Wed, 4 Oct 2023 08:36:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242432AbjJDMfp (ORCPT ); Wed, 4 Oct 2023 08:35:45 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F03B7121 for ; Wed, 4 Oct 2023 05:35:39 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422938; 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=ch0dJixaaY+pPoIMtZ/2D1P4Dl6dWsbaFTlXDeDmHfo=; b=EWEnazDZolfpBGPeMVQr4P6bwSvWc5rXvr3cujc035imvKbovtJuoA3eSiXKwGIwg502Is aKE/bAslzFSsygvIc/mbRqupzsiPyuW5lngr2Up5h9AszVVMSqO9Af8IFSMyTUfgFfXOqu clPbDFGEGxtZlXOKIJEhNpGbQqwSioYrpTr0aFrbgeDPK6ioy/SExPalLFHCLn3nqqOgif jC1JNHIQjBb+uF9hrjRm4DwAXGWxwT/kc1ybLhv+MN2icWryR7HBApEU8Uchs8t2a0/r7A tuZ/tjtrHP7aUq2Nv8ueCgIZWacA6OeCxNarvL4BJynBNhg9y4Mm4WnaakhOtA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422938; 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=ch0dJixaaY+pPoIMtZ/2D1P4Dl6dWsbaFTlXDeDmHfo=; b=jrRtLk7S+jsStbrVpfrcFWHXpIo5Z8IQZdT0KGNlw/PKwrqR97BmQk3LLty8vm43LyZJnp j/aQNVezBwbpqkBQ== 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 , "Richard Cochran (linutronix GmbH)" , Anna-Maria Behnsen Subject: [PATCH v8 22/25] tick/sched: Split out jiffies update helper function Date: Wed, 4 Oct 2023 14:34:51 +0200 Message-Id: <20231004123454.15691-23-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=-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,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:36:17 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1778828451814198887 X-GMAIL-MSGID: 1778828451814198887 From: "Richard Cochran (linutronix GmbH)" The logic to get the time of the last jiffies update will be needed by the timer pull model as well. Move the code into a global function in anticipation of the new caller. No functional change. Signed-off-by: Richard Cochran (linutronix GmbH) Signed-off-by: Anna-Maria Behnsen --- kernel/time/tick-internal.h | 1 + kernel/time/tick-sched.c | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 206010ae2a53..7dbf5ab43d06 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h @@ -158,6 +158,7 @@ static inline void tick_nohz_init(void) { } #ifdef CONFIG_NO_HZ_COMMON extern unsigned long tick_nohz_active; extern void timers_update_nohz(void); +extern u64 get_jiffies_update(unsigned long *basej); # ifdef CONFIG_SMP extern struct static_key_false timers_migration_enabled; extern void fetch_next_timer_interrupt_remote(unsigned long basej, u64 basem, diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 7e1fdbc6d5f0..169886a87cc1 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -798,18 +798,30 @@ static inline bool local_timer_softirq_pending(void) return local_softirq_pending() & BIT(TIMER_SOFTIRQ); } -static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) +/* + * Read jiffies and the time when jiffies were updated last + */ +u64 get_jiffies_update(unsigned long *basej) { - u64 basemono, next_tick, delta, expires; unsigned long basejiff; unsigned int seq; + u64 basemono; - /* Read jiffies and the time when jiffies were updated last */ do { seq = read_seqcount_begin(&jiffies_seq); basemono = last_jiffies_update; basejiff = jiffies; } while (read_seqcount_retry(&jiffies_seq, seq)); + *basej = basejiff; + return basemono; +} + +static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) +{ + u64 basemono, next_tick, delta, expires; + unsigned long basejiff; + + basemono = get_jiffies_update(&basejiff); ts->last_jiffies = basejiff; ts->timer_expires_base = basemono;