From patchwork Wed May 10 07:28:14 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: 91924 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp3431482vqo; Wed, 10 May 2023 00:35:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7gbxWmk3cPZY/asgtOs5ikoOjrl3OSVBa73T03Wb6no3WJpOtogSKQDBcdH/8JdITkZSKI X-Received: by 2002:a17:902:b20f:b0:1a6:8405:f709 with SMTP id t15-20020a170902b20f00b001a68405f709mr18039352plr.20.1683704108670; Wed, 10 May 2023 00:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683704108; cv=none; d=google.com; s=arc-20160816; b=sCLtwJ70JA0RTXsNqu0Y9RuHO4eeJfBS9gmhiP0t5MQEd9mR3bvPE/C6zLBj2/dhlW gZoFBpwA7GoRRBslgBYwF0ZsY0pdcjqgr8+j4Lwqplmap2OeCrJXJciallgqENuom47t 1s5kcdQ04afViNRHvREZQJRoMAODQEmqsRtCBA4QskgtLhRjAoZCGPRGivTcepr7LMII HMrZ7CG3hJwUWKGSYyscD9N/aOd1mhtBplE+FB17WCJnN3dX6g9DCwItFJEyM4GMM17Z pZu0OIuttaNA3RSUrL7xClFo0XS7J1aiqz/l/+wzaoO/kDrx8T/vThtp5PL1d9U24/HY rYng== 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=ZIGKIf4Z0AsCend9uaXIeTu+m62vPWVrk7haHbUMXy8=; b=OGj+t8hxyua8xLhK+2oexMEwcdO/Gc/YrBwBkvD1kIeMfKg3Fb60sifZgHzQdYykKd AIMIIFP1ppnbHJZ2+OFVd++8AR8xtCO3LlXhazQxxRswebcZjBYpQ6RiYpgx+Xft7oLQ uM2XwsJuoQ0g0Ia+Va72TmEjkgS2iqPh+uAnVxN9UufpznfXkAR7XwQtAX50oADNj4qW t3AK7FTfLHSa/DQP7g8LC2+tyYOXGjs1BSz/53m774Xt+ZGxYp8Z2P+GZi64IDXBvcKg utcefTlwQ1te67wKsIMvMJ28kqstLGFkmu+iASOeZnTPmZSboQ+I7bhc9NksralaUTiv 2Bvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="QlhYI4/J"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n11-20020a170902e54b00b001ab18f70feesi3615980plf.373.2023.05.10.00.34.53; Wed, 10 May 2023 00:35:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="QlhYI4/J"; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236015AbjEJHau (ORCPT + 99 others); Wed, 10 May 2023 03:30:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236211AbjEJH3z (ORCPT ); Wed, 10 May 2023 03:29:55 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1A7C87AB0 for ; Wed, 10 May 2023 00:29:34 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1683703726; 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=ZIGKIf4Z0AsCend9uaXIeTu+m62vPWVrk7haHbUMXy8=; b=QlhYI4/J5J2vKwJijQZrNRoGyUQTJeZX16KejNgtqq2JanWWzoQhlf7m4YjSHPtchOR3kp m4S3x7HM2XB8bNpHPPDcnu04SRkOxqq99qukvOmWBAfdYm/1jhVMaGSxCR4jLsSSN3p3Ic /tdrAIIuSpos3jHShREl+qyS7ezaUjnrCemqjJbLXCIRAyCnNy1RDPt5omaqWOYXsY7mTE jbBhXdViK0fa2YhwOEqLDrlJ/rH1aa4M3EQsG0yJD7wo+zTl87J9wKwS4AqyJQFfX5r1We hwRGKWZgYVoHdynwWSD9F6xQT63PAv7x+DdkQ7ijZO7vSFpqwFVD4P6mt2MAKQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1683703726; 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=ZIGKIf4Z0AsCend9uaXIeTu+m62vPWVrk7haHbUMXy8=; b=G0Mzvhor2kV4GKNj/OHrSWqAZqgI1l7R9ATeyv1KZbjj29GcTxUXJvuwstvD9LMZjBFXY/ x36BDWhBaH29kWAg== 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" , "Richard Cochran (linutronix GmbH)" , Anna-Maria Behnsen Subject: [PATCH v6 18/21] tick/sched: Split out jiffies update helper function Date: Wed, 10 May 2023 09:28:14 +0200 Message-Id: <20230510072817.116056-19-anna-maria@linutronix.de> In-Reply-To: <20230510072817.116056-1-anna-maria@linutronix.de> References: <20230510072817.116056-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,T_SCC_BODY_TEXT_LINE,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-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765491719472059381?= X-GMAIL-MSGID: =?utf-8?q?1765491719472059381?= 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 c7bba0bb19d9..630ed43cd8d6 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; # endif diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index 62836490ba4d..847c459c01f2 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -787,18 +787,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;