From nobody Tue Feb 10 16:18:34 2026 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 D0EADC77B7C for ; Wed, 24 May 2023 07:07:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239824AbjEXHHG (ORCPT ); Wed, 24 May 2023 03:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47818 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233779AbjEXHG6 (ORCPT ); Wed, 24 May 2023 03:06:58 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B567597 for ; Wed, 24 May 2023 00:06:57 -0700 (PDT) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1684912015; 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=PQ3NXQMtig0Ydn+DZ27wQ54KKOjUtVfs2xndfW98O6U=; b=G5siFWrsT9q+G+iRVJWKholCzvsqc7TcdsDMp/QlYXgteNVLws2xuw8XtztHTAlarVBIof 9R4n7fd2KpJa7lAKm52rkRFmKgX5VMLZYHXiOOiAFxygm9H3a5kAaPIXBZAx8YcOAqRYni hWhSPSjbodoOfMTqjOPTyPEXJeeF9dGq+xS3LVlVCNbfl6OkzyrZQDn7QkXMuXLMjBxCz6 xN6lqBFTb9014+NhdixwYua53dJ3whHrSLRF9Ai9xG6AwDQ04x+bgaREo6uy2saDj100mZ rHhO2W2n1xeBmWYosuF+nALYy7NuCBGDMbvyeQ5CUrucHaWscjr29ucikDrrsA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1684912015; 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=PQ3NXQMtig0Ydn+DZ27wQ54KKOjUtVfs2xndfW98O6U=; b=/rAPckayV2VcrKm9f5e7XUlQZYPYkrm3FYI+hfFAH8ns7bpLqp+w7ah8pQixFXqjffY4Rv p3PJ+rr35QetIOAQ== 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" , Anna-Maria Behnsen , Frederic Weisbecker Subject: [PATCH v7 01/21] tick-sched: Warn when next tick seems to be in the past Date: Wed, 24 May 2023 09:06:09 +0200 Message-Id: <20230524070629.6377-2-anna-maria@linutronix.de> In-Reply-To: <20230524070629.6377-1-anna-maria@linutronix.de> References: <20230524070629.6377-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 52254679ec48..62836490ba4d 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -831,6 +831,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.30.2