From patchwork Wed May 24 07:06:26 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: 98338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2651133vqo; Wed, 24 May 2023 00:11:10 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6si2t50grZldt5hEynH+oNwgc57AEPvrrlyEtpoRvg7UAfcw9vnk0ajtkHAViZ3m0MtzI/ X-Received: by 2002:a17:902:c942:b0:1ab:94:1ee4 with SMTP id i2-20020a170902c94200b001ab00941ee4mr17560981pla.2.1684912269887; Wed, 24 May 2023 00:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684912269; cv=none; d=google.com; s=arc-20160816; b=MIlsVHi2sMpJSyDNnyD3pbbkm3/FaU6eeQ0JRMn2Z/qNDgsqNJpAISqfPAUUVi6LrN Z2jc7M899EByTAFkQwVcwojTmhTfxwrbu3Q40VoqmX982A8I2SJSDooB/T4k80sCYFLv /pIEyqDeertsc5WrHJ2lNJxg72ngd229nXq5AjTRWGGhNPFYSEGTDFqGFPl7W22YYKuC k+T5RvUmZw9LCCwAmxhTFosLM38ysKZXacqcJmNo9oRWITNlsz3NUewWVdjxennjXu3Z Gn2fMsqhM2h2y1TjviV2LM5hwaRzGQN0oj6LfXPcTJRkAaWetKM5wcXW4KbpqGPEDGB7 cPCQ== 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=YzExw9CwT/xYQwHozBW+vEKUpVUnPxVAkZD2Ieh/LaM=; b=mpKgso9Zeu8KyOwTwjDIaL/zP4JmoMw6gwrQndbuKMogWJW51NzkO0bL9iBm9e5pnz TmGoyP6R5dWYHbupAuU73IADLfCS9GCiAB2Cmg6HbqqKTBuKBP/ABzAdYgOVyQDE2JPr uSUUzXxzHbTNQYlCLdAsXFxIRJNdYB+nTRmouqBx2fbPgR0FESDjghGnKyDNI+5je/zC KV5ZV8DkW/t7GPheDsGkmB/pHOyGFsuWpDXxJcVT7d8YB/F8+HpyH40oM+73wAwYVPnX LWaGyA4OkpSxwQ+yhgg/qJ5MKuS7I7FJvW9CEwuh+RfjirRS6ms6ypL3arfh6mcFoPTe ej2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=lHvpjZ86; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 v4-20020a170902b7c400b001ae4c3bbb0dsi299773plz.145.2023.05.24.00.10.56; Wed, 24 May 2023 00:11:09 -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=lHvpjZ86; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S239985AbjEXHIb (ORCPT + 99 others); Wed, 24 May 2023 03:08:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47894 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239918AbjEXHHk (ORCPT ); Wed, 24 May 2023 03:07:40 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AFE691BF for ; Wed, 24 May 2023 00:07:07 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912026; 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=YzExw9CwT/xYQwHozBW+vEKUpVUnPxVAkZD2Ieh/LaM=; b=lHvpjZ86cvEeJSeF5EV5nGiDMEnPGsM89BE8/gGu8yVg0iwxws5hQFXGDpyd+cQdo7AHo0 ekOT2qSeeyCGY5ZkvHwipS464J+zIAumoHihgNH4mDskUP5K6OJCOevsKyW4oGo4PnIC5G ppA/YGfqRvdCBlKpHnUmjkTYbRNVTvxL4GwHekY5YbUNfauajSwzUfkELWAuscsXcFe7O5 9YBWPpUp6dbMCB2z1dYJQ7/AQK7bYalkHkC1+SuO7C3KVuDLaIuiP32MSuBSgcjkyQzMgi 5PRPbfoQWML/L96uVZRpE36vy/ZK2ShzH6aMD28wN4fXADbYN1smfjmHTzk1BA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912026; 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=YzExw9CwT/xYQwHozBW+vEKUpVUnPxVAkZD2Ieh/LaM=; b=XLvSwUscNPoTa358YL9bKhPMT2HSbQXx9gPfZw73Kx0hBid+oWgLDqUkekiFQtw6+0Yc2S MRrH56vJTHmBD4AA== 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 v7 18/21] tick/sched: Split out jiffies update helper function Date: Wed, 24 May 2023 09:06:26 +0200 Message-Id: <20230524070629.6377-19-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-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 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?1766758568631021043?= X-GMAIL-MSGID: =?utf-8?q?1766758568631021043?= 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 9b738117b2ab..34d44fb50c81 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 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;