From patchwork Wed Dec 20 15:59:08 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: 181724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2746835dyi; Wed, 20 Dec 2023 08:08:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IF6x6xEK50kZ2PzRzr9rcZGUFjSjIlqvGizWNzIhxzxn/gEQWVxVUCpzXc9iBzucQwuFBG/ X-Received: by 2002:a05:6870:858d:b0:1fa:df72:9ed5 with SMTP id f13-20020a056870858d00b001fadf729ed5mr23204050oal.38.1703088518376; Wed, 20 Dec 2023 08:08:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703088518; cv=none; d=google.com; s=arc-20160816; b=JbKNqHMD8UzD7OGdPd4kzj/UAKSNZNUNqwxl9gUVKZ5jxCe4LFy+H2KUXj7EvKyWyh 8P2i/m/67eK9Vt8OpI6a8RJsHCbzcZJM6YJ+9gxSAi54PonWX+C/EvWfRAmC37XYQW0K pvFkk/N0ztFv/TE1txdLaITXg0sTvT9iMW1DVDdaOhaoCY+P0HxtyHsKV33ynuR9Vy7I Z43+CP4/A+NjXgq4i5egK2cG6e2tixGI2bgiDngLZf7JMKDnp65uoK7tQtbHBCHpx7vU qL2rIqbsc1MUHLqTk/gqrhVYA03qin/ulAgym0Irug+FbpSOd0Uilj4QdMSdwc82Hhuu zEYQ== 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=B2cYFFxbS9r6uTryeX9Gz9Qr7bZHoLddNK2Xwnf8vnc=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=umu/7ZEmdYyxU0/kHWeS15+Art2f3XRZbVXTdFerDr7e7+JkLePnT9VRk1NxBRq0/l sC5SEIalw+yXNY+RWaEnL/LvmXJHJ7hqJEbckHeSEMn8iBpOAM2Or07GPKkuY0+ns0E8 FTzm1iUVvAD/Od6KYqqiPe/IkMuVfmyr1zBqV/kaD8rnjL/OSZEO1JZtGs7hCWK4lvRQ K0suCJ+CUgdieML0pFmNLl2uk6xRhPhjZsjnOhxCC7e5nOAEpoE+0o0Ec+ZoCT3wh2Rt HuSSRAZjiV/x3WG3WURNNRcGI1D+4x9E8YF7lVYSRGuUkqRR+rN+GXxjIVZdqYg8bGro OhYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rDQvxYM6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-7229-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7229-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 o13-20020a65614d000000b005bdf5961646si21272969pgv.268.2023.12.20.08.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:08:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7229-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=rDQvxYM6; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel+bounces-7229-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7229-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 D1AD7B26193 for ; Wed, 20 Dec 2023 16:01:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B2A694A98E; Wed, 20 Dec 2023 15:59:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rDQvxYM6"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="rUHeoUbw" 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 ACC2447A66; Wed, 20 Dec 2023 15:59:10 +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:08 -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=B2cYFFxbS9r6uTryeX9Gz9Qr7bZHoLddNK2Xwnf8vnc=; b=rDQvxYM6LdIHH32XQchXW1nY/cDUT336SDlAX1wyV9Ghnrm+iaRTrQEjoX6GwRoqtAwVR8 JDB//jHSQdzCbYcczaERLQoMgBxHTiFzOThSw5lZLCGI+DLbeQeJN5H7rHU7Q8a57F28Ne rdnzz6KnzGHnBD0JedGna9GGgNtyYKC6jnF+4lGGjFQ6Dv8X+dIKQ6+Z7TK7B53dMOd9tA 9D87OfEBOKAbgMAISimXynpF/WHKaB/AaMjcwpQe0PYU2FgBSvJmkpHb62M1turENzg/Mx HbbLK868DaluFH4/ciOJ4ym7qYP0TCC59f3xG0FrrLZvu2Cm2Lfi9ONsJDUYdQ== 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=B2cYFFxbS9r6uTryeX9Gz9Qr7bZHoLddNK2Xwnf8vnc=; b=rUHeoUbwRtlZae6xeFbGxr3phvxxuwp3KTRrX09n3IjEUnETsBJhuweeNIaSPFGGheTzM3 sRz1PNGA5DnGqTDA== 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: Clarify check in forward_timer_base() Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231201092654.34614-9-anna-maria@linutronix.de> References: <20231201092654.34614-9-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: <170308794817.398.17855561566614353854.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: 1784071181867783523 X-GMAIL-MSGID: 1785817746483798647 The following commit has been merged into the timers/core branch of tip: Commit-ID: 8a2c9c7e7848d7f63d38b698209148b5bb4ba7f3 Gitweb: https://git.kernel.org/tip/8a2c9c7e7848d7f63d38b698209148b5bb4ba7f3 Author: Anna-Maria Behnsen AuthorDate: Fri, 01 Dec 2023 10:26:30 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 20 Dec 2023 16:49:38 +01:00 timers: Clarify check in forward_timer_base() The current check whether a forward of the timer base is required can be simplified by using an already existing comparison function which is easier to read. The related comment is outdated and was not updated when the check changed in commit 36cd28a4cdd0 ("timers: Lower base clock forwarding threshold"). Use time_before_eq() for the check and replace the comment by copying the comment from the same check inside get_next_timer_interrupt(). Move the precious information of the outdated comment to the proper place in __run_timers(). 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-9-anna-maria@linutronix.de --- kernel/time/timer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 490ff8e..f75f932 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -944,11 +944,10 @@ static inline void forward_timer_base(struct timer_base *base) unsigned long jnow = READ_ONCE(jiffies); /* - * No need to forward if we are close enough below jiffies. - * Also while executing timers, base->clk is 1 offset ahead - * of jiffies to avoid endless requeuing to current 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 ((long)(jnow - base->clk) < 1) + if (time_before_eq(jnow, base->clk)) return; /* @@ -2021,6 +2020,10 @@ static inline void __run_timers(struct timer_base *base) */ WARN_ON_ONCE(!levels && !base->next_expiry_recalc && base->timers_pending); + /* + * While executing timers, base->clk is set 1 offset ahead of + * jiffies to avoid endless requeuing to current jiffies. + */ base->clk++; next_expiry_recalc(base);