From patchwork Fri Nov 4 14:57:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 15622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp456168wru; Fri, 4 Nov 2022 08:02:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7dpjHcRj9yxXlYrOcIhsXbhMNh6Hr/D5vIlR5Bd2Dxahd2BjDs5L3NJjPFTVl41oYCxdb1 X-Received: by 2002:a17:906:6a24:b0:7ad:f2df:51b7 with SMTP id qw36-20020a1709066a2400b007adf2df51b7mr18813954ejc.54.1667574175197; Fri, 04 Nov 2022 08:02:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667574175; cv=none; d=google.com; s=arc-20160816; b=grEn36tM5GxpH+Ar8ZkKPe8+1jPOH9+28oBpcqYveX13HMWJVhNwdYbzLJu7Y+WzLD xda31Uvn62xAjrckguf8aOTqwbW9N2W/iSr/f47WgS4I5jsWRzZzz8c8QaZqQURD9njS uQAGirokDS/b0mE1Sr3CQIsjRg4Y3lSYCvgVsO2W6pOyz1Jp4Ov/bU5IVc9xD4uPn9c1 VH9WjRK1gUtg6vyEzz3/z3Tn6weHh7A5snfzcc1NXZkxQXMnpwewLNz8USJ/putbJKOo H0zejLKbWrCg87htjKUy+RgtPiW1S13hJVRSy+JcWI6mRXFbDI0Y6tndP7VTVOmTgc6P UlHA== 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=7kvCElohZyUyNJGM2JneGjqwOan7vBCE2nbaLgbbE24=; b=ako+KdBKaoeHtbNjNl4i1Ig515Ahk+Ur6m2OWDL6g2e5PsMWwzZViVL1hAd4EnmF/N 2R1aZYpi+lQxiD24DO+T0nMBZ49X4M2iOqL+f6SZxwbOu1HJKSfXgTIPT42USJejNYtD M/E8yNSm08FlPaOdBDoirst3BpRK692nEY1UxNujMB+rNjkLrM+QH5Spa2o9/C7EcQ3+ nr7hiT+RyPCXvqa4hy2t3GmBr7ftrN44vNvH4CoFKQqIfNaEdxVoxz3fXsPQ9U2fktgX Ha1YrjJce01EGe9mZsF2W0haPnELeB3vXd+vPkTTsnjsgv+dT5LP4Pm9M9owOBUMbJv2 CLEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=0tuI8buT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XvrogLHg; 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 y7-20020a056402270700b0045cca8f9a0asi6228985edd.580.2022.11.04.08.02.31; Fri, 04 Nov 2022 08:02:55 -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=0tuI8buT; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XvrogLHg; 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 S232357AbiKDO7C (ORCPT + 99 others); Fri, 4 Nov 2022 10:59:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232282AbiKDO6G (ORCPT ); Fri, 4 Nov 2022 10:58:06 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 555122EF7B for ; Fri, 4 Nov 2022 07:58:00 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1667573879; 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=7kvCElohZyUyNJGM2JneGjqwOan7vBCE2nbaLgbbE24=; b=0tuI8buTxcQd683GsIeTB2XnvF+yOTjJCOWEzNfR1pfDAmxN20GCUlC36qmFby74aWOo0b Jp1pe1Q7/zkmL1fCF/v8jjHO/UnzxZdHgcX30pQ1tKzk6X8wc2gLBVlzbzXJjm2b2EIBat 3X/5b3IX+EnjHS62nyFo7zcHS6aH4obDW2HKWCTptp8wZmLJ7xSwvEUJWpmr2mrBsM4TWl UGgmRmBnZYt7IehlzhAi2yyc0IIs/QMzUu8oK2fbAVu2DNu+Eks43tEEvRG6Zjhkz8Tn8l Ytxjkl84wObu9x6ASDBdLLk7xl4tToDtB8igF2/YNn2ShanmE65Dc86xxB7fUg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1667573879; 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=7kvCElohZyUyNJGM2JneGjqwOan7vBCE2nbaLgbbE24=; b=XvrogLHg8qBegViDEiUEOPcLE9nQosfe7dI6/vK+t49B/gbCFUaDJ8+tS/0F7HBSAJperm ZSI2edb40Ftv/oCg== 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 , "Richard Cochran (linutronix GmbH)" , Anna-Maria Behnsen Subject: [PATCH v4 13/16] tick/sched: Split out jiffies update helper function Date: Fri, 4 Nov 2022 15:57:34 +0100 Message-Id: <20221104145737.71236-14-anna-maria@linutronix.de> In-Reply-To: <20221104145737.71236-1-anna-maria@linutronix.de> References: <20221104145737.71236-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 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?1748578258354513480?= X-GMAIL-MSGID: =?utf-8?q?1748578258354513480?= 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 funtion 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 | 20 ++++++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/kernel/time/tick-internal.h b/kernel/time/tick-internal.h index 7b65abc9d803..8f99e35e75b4 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 7f7bfe8b498d..868679ff3421 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -782,19 +782,31 @@ 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) { - struct timer_events tevt = { .local = KTIME_MAX, .global = KTIME_MAX }; - u64 basemono, 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) +{ + struct timer_events tevt = { .local = KTIME_MAX, .global = KTIME_MAX }; + u64 basemono, delta, expires; + unsigned long basejiff; + + basemono = get_jiffies_update(&basejiff); ts->last_jiffies = basejiff; ts->timer_expires_base = basemono;