From patchwork Tue Oct 25 13:58:46 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: 10806 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1025477wru; Tue, 25 Oct 2022 07:04:11 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7m4U0sbC/069FnimTqb/E1ybLJR27/ykpQ09aRhr3kS+ddX1qIdaRJ9/hKrMSLLhYg3+ey X-Received: by 2002:a17:90b:1a85:b0:20d:c705:92b9 with SMTP id ng5-20020a17090b1a8500b0020dc70592b9mr62458932pjb.213.1666706650703; Tue, 25 Oct 2022 07:04:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666706650; cv=none; d=google.com; s=arc-20160816; b=TcSEyljB4dF2fJ9H+l1DtrUqnCt0Vxb6DlEhGG+kGz7PpQI+epP08y+JXLVBJtr8K7 rsSY3GckHTVDqp3uOXytRqFBnoU0iZEOAd4rFVEyfq1I4F0xnTWAoFsAHXb8BYix+ch7 eyA3GNnsreaFileQJMsfaBIpylauT11g9+zhmjUW3O/jVah0Y4J+I0yii6xnFpbLjofy bewyfAI+eEoJHGzS/DfXfU41ULTEKND96ohoPRofCr4bGwPr3R3NJspebrGEU6NR4ZDD F2gVbSXGv+tHJNAwI6ckruCUtZcebmVu3H7hk+jlVbrPbw52Z0Xvmi2QUhHBpUX2+P38 VM7g== 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=hu7QxUjwRbxG/okn6CG/yMbntoc2EZ9KmIghcUJ/Me1U5xUi3YWxuJVqXEI1ZwezgM esGQaAMZFx5H/sn9Q1tTpMxmU8fXkYzTSVFuzXQp90mhMQC88dnzmtFpZyVdeRvEEKbj jGv14EQb9fEvf3/jTU3VSsvSwxsblya0G8Q438NHZ1bD4hpFIW9H/BuWZ+Gg9qvvUBLW HJ4qswxn52Ep383aqc8zQGMUXEs+T439BKPwmxF9g6x9bk+UOtU8XsgPRyOPHOXZPY4T DCYoHr2oV7bNiXmoQGqGIo1fyDI7juQr255u6zfAlWgVjlP+ryGkz2caqfohw1gUK/vm yMMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=1rvNmBFH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=C6EV5i1S; 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 c7-20020a17090a558700b002009ed52bf6si3163796pji.19.2022.10.25.07.03.55; Tue, 25 Oct 2022 07:04:10 -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=1rvNmBFH; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=C6EV5i1S; 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 S232321AbiJYOAt (ORCPT + 99 others); Tue, 25 Oct 2022 10:00:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232066AbiJYN7h (ORCPT ); Tue, 25 Oct 2022 09:59:37 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B98E65B4; Tue, 25 Oct 2022 06:59:29 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1666706368; 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=1rvNmBFHfqTzHK97MH5AwbRl/2ohHfzGQXVUxbumwMMYUql4LUSdarJUdEjUB/2J4INa2K lb7eCMqax2eY+QdE5NkIEWoATeFTZKEEEm1oRFwRiOpJRsPKqKp+tSqGRzLtRV4aLdiH2P KEVQZy2lVd7P0D+aSDHIplsRslihKWsjDhTmSMFNiBF41svMCJCRAdEA0gWt3snZFlkwYH 7NbrCLJNIRM4agpP3644czZxZ7bz7yAkdHlldQvFKL5FIqrzkb2y04faAPB8sDj1+Y7RAL RFrLzNG4SgvvjbXp+w/419e241dsGffAmyJedlzDcqAthmonyySAoVL6agJkMA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1666706368; 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=C6EV5i1SHcU/aOMrMx8cq4g8OZp2nrmCWSD0GaxibGuR5WE/UzyOd0FqnDEfWOp7NpytzM ObJWWF8A79a2cCCw== To: linux-kernel@vger.kernel.org Cc: Peter Zijlstra , John Stultz , Eric Dumazet , Thomas Gleixner , "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Arjan van de Ven , "Paul E. McKenney" , Frederic Weisbecker , Rik van Riel , "Richard Cochran (linutronix GmbH)" , Anna-Maria Behnsen Subject: [PATCH v3 13/17] tick/sched: Split out jiffies update helper function Date: Tue, 25 Oct 2022 15:58:46 +0200 Message-Id: <20221025135850.51044-14-anna-maria@linutronix.de> In-Reply-To: <20221025135850.51044-1-anna-maria@linutronix.de> References: <20221025135850.51044-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,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?1747668593204387023?= X-GMAIL-MSGID: =?utf-8?q?1747668593204387023?= 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;