From patchwork Mon Jan 15 14:37:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 188193 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1744651dyc; Mon, 15 Jan 2024 06:42:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbYfl261Ztz2FSv8pJbtQ/FAjBOBzeZ2WneTdu6Fl5QPq3xUmfM5GtCuJ/Vsoi/E7y3dfH X-Received: by 2002:a05:6214:c6e:b0:681:5d1a:883c with SMTP id t14-20020a0562140c6e00b006815d1a883cmr2683987qvj.43.1705329740018; Mon, 15 Jan 2024 06:42:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705329740; cv=none; d=google.com; s=arc-20160816; b=fHUVmc5elKpwLcyXjvkqyKZ16x3ga6jv0TdO8YM99WvXvpGoZKBsp/lkfxHB3Bcy09 HuRNLZXUkrGV1lrC0RdbdU6dEqi3wc8z3wefEannBlIEovU3A+AZymt4D+l2tlGeM7Db BrFU7oQsuVct4AtIM/y1NgKdrFhKYNn3C/QuU2YkvckjD0mwVzT+nf+Hp/nrhVSicqNW MSLij1aDJhRDkVlCJqN/wIrng44FMVF4POCLhafAJITUFf5OWPPF29jPCT5WdQ9H23oa qZyl6cfZ+EgruiiSzD2rOSSJgvfwXOZoxMyFhST1qARsJ5WHsyKEsAYQgdhZEaGpwAFG QMVg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=FfYsNU3nxkN76DhpfApxecdpLCdc0FbmIjtWoc6sI04=; fh=H6hHKnScvHhKAB7z8Wb75LBNJxB0aNyPhv3ZCgyEYhY=; b=zpCi1+JUOcabKg3PItV+DAfpddjZ+nlowDvEuatofCwSQd4SZYnDLjjHVQ8deC556q Lw94nvqP63273okSyGS3koka+f8yFu1Bljlwr/0cIp5VXH3eRL+mys7NAgfRdJRijVGN 7OQjRnljQpxSHeuge6Q7b0c2ixEWcxGHPmWbEoS4rO/bG7jXha+K8CbhHGSNNwivyslA BanPOwIpGYaC4k2bxGv47FnYMg6oqnY0Hc42jLQVCZzEetaqurrNJ5vaivYDI8x83jtu dUbNlY1+vVHLZ6LwAqkPV1GgO9gdR9YlLs5aB/TBJFd5y8aHrwt/rnp/kdxPnxANP6bG 65Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y12vRgDO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-26112-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id n18-20020a0cdc92000000b0067fe06ad843si8000354qvk.518.2024.01.15.06.42.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 06:42:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26112-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Y12vRgDO; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-26112-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26112-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id CB1E51C21BF0 for ; Mon, 15 Jan 2024 14:42:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34E7417744; Mon, 15 Jan 2024 14:38:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="Y12vRgDO"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="YRhjk5FM" Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE71118E08 for ; Mon, 15 Jan 2024 14:38:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1705329492; 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=FfYsNU3nxkN76DhpfApxecdpLCdc0FbmIjtWoc6sI04=; b=Y12vRgDO9utSd0YcJu5fn9UXbjopBvL7kF/0XnYRwwON7Bf/G3o/T4W3sD6QcoHlq1AIDs lNwLRS+UBIPbe8NXsen4ktizBy/saBwcZ4SwljENCh+vx/9bucVeQlNuWqytSP/TkZlm8r iPuOqBb9hPwkH3QgqBlYEUhj6jtuPtlLPqRPNObeRhoXY4lMXzD+/V72lcIcHzfQMiCJcQ z1scyh6FAzsxuawiVN+csfo6MNNBJZvd3dM0WG2KjzlsR/Zb6VU07VrMqt+H4omH3hOhlH Wam9gwWACpqT6lZkLnGh6HZSvhN5Or9R57BW6gfIQzomE7vFRjpnbqKo7wGBNQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1705329492; 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=FfYsNU3nxkN76DhpfApxecdpLCdc0FbmIjtWoc6sI04=; b=YRhjk5FMhkO0wLgA/Vbh2OR1jdhNeTFpGp1jFIrxYWwr0WG9QxF6CHHnyEgwptnnUr01IK Pt1zN3hGlWm30bDA== 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 v10 16/20] tick/sched: Split out jiffies update helper function Date: Mon, 15 Jan 2024 15:37:39 +0100 Message-Id: <20240115143743.27827-17-anna-maria@linutronix.de> In-Reply-To: <20240115143743.27827-1-anna-maria@linutronix.de> References: <20240115143743.27827-1-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788167837399939791 X-GMAIL-MSGID: 1788167837399939791 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 Reviewed-by: Frederic Weisbecker --- 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 8b0c28edbd09..ccf39befde85 100644 --- a/kernel/time/tick-internal.h +++ b/kernel/time/tick-internal.h @@ -157,6 +157,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 27f1a2ae7f39..a3eb5165d439 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -799,18 +799,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;