From nobody Wed Sep 10 02:01:41 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80556E7B604 for ; Wed, 4 Oct 2023 12:35:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242380AbjJDMfg (ORCPT ); Wed, 4 Oct 2023 08:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233336AbjJDMfc (ORCPT ); Wed, 4 Oct 2023 08:35:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9A09CB0 for ; Wed, 4 Oct 2023 05:35:28 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1696422927; 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=Qz4nJBaG6XRtjj3mRkMTDjA4wkxAWKGzl0cHJtp9Oe0=; b=BIozC7PyZ4VhQOCf4rAfBpbcQ7TgnF/JfDtlw7mlsRDKvWNbWOyEamfwSre+uzcIh8bmNQ MNg+c1mk0p6wtXauMY8pQrNRb5+qGggoexuscNVjelnE8Sv6zezgM6Ym7tiaEQTBHbKlEo t9qGlU7wzEpmqeQ2yWwqvCUsvocrgXbc/Zg2Dn4AEpdo2TNzL3j7PGIzH2cpdBvwDtFYEI 6HlUqNBd9Evc7k30v5rm1GNYhBITNjeTggg3PwIjZUKVEx/vEkrRdLvouCEyODoFyL2c3q /WGvqyUNT2/uvcFL45xHRBWxSP5Qm4DAB1CTgpc2yLbS/xQag2tChfePA+o7Ew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1696422927; 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=Qz4nJBaG6XRtjj3mRkMTDjA4wkxAWKGzl0cHJtp9Oe0=; b=CHFn5XMk74YVpQGH5n+8y0lqHnXKS2zTHVWFKCa+56NDFEzcfcQW4uiJDc6bqoVS8IKl4w majPpeh3Rwnn8WBw== 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 , Anna-Maria Behnsen Subject: [PATCH v8 02/25] tick-sched: Warn when next tick seems to be in the past Date: Wed, 4 Oct 2023 14:34:31 +0200 Message-Id: <20231004123454.15691-3-anna-maria@linutronix.de> In-Reply-To: <20231004123454.15691-1-anna-maria@linutronix.de> References: <20231004123454.15691-1-anna-maria@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" When the next tick is in the past, the delta between basemono and the next tick gets negativ. But the next tick should never be in the past. The negative effect of a wrong next tick might be a stop of the tick and timers might expire late. To prevent expensive debugging when changing underlying code, add a WARN_ON_ONCE into this code path. Signed-off-by: Anna-Maria Behnsen Reviewed-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker --- kernel/time/tick-sched.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index bdad2abdc0c7..b3cf535881a4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -842,6 +842,8 @@ static ktime_t tick_nohz_next_event(struct tick_sched *= ts, int cpu) * If the tick is due in the next period, keep it ticking or * force prod the timer. */ + WARN_ON_ONCE(basemono > next_tick); + delta =3D next_tick - basemono; if (delta <=3D (u64)TICK_NSEC) { /* --=20 2.39.2