From patchwork Wed Dec 20 15:59:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 181723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2746435dyi; Wed, 20 Dec 2023 08:08:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEw4WVdKLHd0iIIFl5TdHgOF0h7cyeP1GSJZ5F3z7j+qJ1S/k1H2cqt+eNeIbqtNATpkoOr X-Received: by 2002:a05:6e02:1a8e:b0:35d:59a2:127a with SMTP id k14-20020a056e021a8e00b0035d59a2127amr30862811ilv.38.1703088487580; Wed, 20 Dec 2023 08:08:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703088487; cv=none; d=google.com; s=arc-20160816; b=JFgp/1Zb87FtU1AysuJBashAaY7xQ26tDCRhbggxH4tFSA0R7Toy0b3U/IQ3gTCAG6 ltca3ycoqatRv/dpvRZARjbCAhGFprjwOvYWptf7XPHLE+oQ8yMuvAHP+2SN8CXaCsc4 Feg2iG4Eqz8Oh0QSf0mdpLNlZYk1LccGT0cKwDrCKR799wMaeUWWTaLWlR007aJck+uU uWPOje6RBKfK0+33kem1cJ9OZbogpK1f3hxeNCoUqJEtFNPM1KGNup9REvpj/zzzA8TB kdTt6MJX7QOuf/j4+NmP5KpShAAAapAuscWudHGrcq80M1xZL9ZtLnx3tHtlZ7D04lBb 0adw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:precedence:robot-unsubscribe:robot-id :message-id:mime-version:list-unsubscribe:list-subscribe:list-id :precedence:references:in-reply-to:cc:subject:to:reply-to:sender :from:dkim-signature:dkim-signature:date; bh=WyGjXO4HU/DxT+MT2cyvv4Bxj8SSc0VCc0LZoXF0s88=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=a4lxviWUZXsFrXq8JChh/+oxbngllFNTMbQLADn01HTA/T8J+e30CmDErndZbUcz/I fFiHdhxnoDfNgY6cBO3UmAMXifnXNqajkLIxGUfDxm3taRlRUkmHg2rw4s2y6bjiW+yM vcpy40xKL7RA1F37ED/rd825l7CUKUF4qNv04VIaa7JxhC8iTp/mG0M1u1UElAWQFa5/ Qla0dVhFX6QpPQOAVa31bZrGgxTJfnA86oosPTTB6FeEUfESyooNXSn8/YQ8icD/xPUY YX90sfZlYXhtTthD+yBifr9AXOCQuKIW5Y7055RqOzs3OWlLdPx0MnB43W6fM5HN4amx jXvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hzaC5rhE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7228-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7228-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id s124-20020a637782000000b005c67e10f240si7641012pgc.312.2023.12.20.08.08.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:08:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7228-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hzaC5rhE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7228-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7228-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 43E21B2617F for ; Wed, 20 Dec 2023 16:01:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DF99D495EB; Wed, 20 Dec 2023 15:59:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="hzaC5rhE"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="PRrJ6v6p" X-Original-To: linux-kernel@vger.kernel.org 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 D75B94779B; Wed, 20 Dec 2023 15:59:09 +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 Date: Wed, 20 Dec 2023 15:59:07 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703087948; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WyGjXO4HU/DxT+MT2cyvv4Bxj8SSc0VCc0LZoXF0s88=; b=hzaC5rhELNs0UNOl/M0wtaQVLKYqyX/bk9ZFQmuEbhSpDEWR2OhTTILVClwA7UXLh+FC/Z a0zVY+M4+jQaxFNb61rwpKT6qb+GDzLaheISgR5UWOe5tOwCh9yKEhpIEgKmWdQNCph8ni 89ee6sD0kWsZbyskj2hrITB1DjW0pQEtQ2xXAQaLIk37douXS3BFfXB1Fz3nF+H7wrbmDA FcpaBvpqS5e4VHUqbGe9Hni7hFL3qYZ+mLGc53/7tQqpaA79gtj/WbXmLxYY48TvyHu3YL pJgsf9rmSvuEundyzeqX+MU9p6oAGzuNSSElTV2ZuMf/jTb58ETX+DRsrOV5Tw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703087948; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WyGjXO4HU/DxT+MT2cyvv4Bxj8SSc0VCc0LZoXF0s88=; b=PRrJ6v6phLFjvPIy6bXt3GSgMv6PD7zEk/E/C5OVW5MXmffxHKd70P6aC07wQGo9pZ8ppX NduyoQy45cLPFpDg== From: "tip-bot2 for Anna-Maria Behnsen" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] timers: Split out forward timer base functionality Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231201092654.34614-10-anna-maria@linutronix.de> References: <20231201092654.34614-10-anna-maria@linutronix.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <170308794724.398.14686394808339432944.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784071182068885736 X-GMAIL-MSGID: 1785817713999983372 The following commit has been merged into the timers/core branch of tip: Commit-ID: 1e490484aa3af42d4eeffabf96d6a02be69d586b Gitweb: https://git.kernel.org/tip/1e490484aa3af42d4eeffabf96d6a02be69d586b Author: Anna-Maria Behnsen AuthorDate: Fri, 01 Dec 2023 10:26:31 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 20 Dec 2023 16:49:38 +01:00 timers: Split out forward timer base functionality Forwarding timer base is done when the next expiry value is calculated and when a new timer is enqueued. When the next expiry value is calculated the jiffies value is already available and does not need to be reread a second time. Splitting out the forward timer base functionality to make it executable via both contextes - those where jiffies are already known and those, where jiffies need to be read. No functional change. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20231201092654.34614-10-anna-maria@linutronix.de --- kernel/time/timer.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index f75f932..5b02e16 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -939,30 +939,34 @@ get_target_base(struct timer_base *base, unsigned tflags) return get_timer_this_cpu_base(tflags); } -static inline void forward_timer_base(struct timer_base *base) +static inline void __forward_timer_base(struct timer_base *base, + unsigned long basej) { - unsigned long jnow = READ_ONCE(jiffies); - /* * Check whether we can forward the base. We can only do that when * @basej is past base->clk otherwise we might rewind base->clk. */ - if (time_before_eq(jnow, base->clk)) + if (time_before_eq(basej, base->clk)) return; /* * If the next expiry value is > jiffies, then we fast forward to * jiffies otherwise we forward to the next expiry value. */ - if (time_after(base->next_expiry, jnow)) { - base->clk = jnow; + if (time_after(base->next_expiry, basej)) { + base->clk = basej; } else { if (WARN_ON_ONCE(time_before(base->next_expiry, base->clk))) return; base->clk = base->next_expiry; } + } +static inline void forward_timer_base(struct timer_base *base) +{ + __forward_timer_base(base, READ_ONCE(jiffies)); +} /* * We are using hashed locking: Holding per_cpu(timer_bases[x]).lock means