From patchwork Wed May 24 07:06:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anna-Maria Behnsen X-Patchwork-Id: 98341 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2653416vqo; Wed, 24 May 2023 00:16:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UIdh8IjUeIXN+LWRMWnvwOQCcX3Z70PPg2myJVw+Im5OzU3a9Rt6j/s/q7mYuSERjknKF X-Received: by 2002:a05:6a20:4315:b0:ef:7aa2:3cfd with SMTP id h21-20020a056a20431500b000ef7aa23cfdmr15815376pzk.50.1684912568752; Wed, 24 May 2023 00:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684912568; cv=none; d=google.com; s=arc-20160816; b=IPY71zRj06qzz3R86kv7l5wE6WiFR8JhCNevWqlqknRi4btLS/y0p2z2qNPalSKQDn 1Oy+7/uWsOXY4YTydwStlZRj/B7MCitLgPQfguhlCRyGBBsjbQDZvGr/PxGlLC2lPwsv cLMa5gKU57TzXj1WgBNILRpa9fz3J31JTzVFnDSeC6uDCSrJBVAC2gEIEolebo/H2iCj pL2bVJUObiGv1LmWqdfWPBODee3Ly9S7owLYOqKhfd5/3bGPGpE9VFa6fXMwjvpRwr5f VtEPx5pEItK7pUaqHBM9sDF/VhkvyUKAor3a4PJ+qhnbaGu0wY41aUu29wBiTE57ZUqO UV5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=PQ3NXQMtig0Ydn+DZ27wQ54KKOjUtVfs2xndfW98O6U=; b=DirZ4MO7MtsQyHB312OWHdPHQ4fRo+ezZJmImfLbIqtwNTB7g826aE4koPt+BLi8PW jgrUkAuVgrHBQmMtjOzJjJSrcq6JbKzs7XazyuuRW5NjTwers/F8ceun/rz+ERvLsKq1 wu9nUGO8yfsyyIhlCJgFhb8COwBM/imoNJCYMQPDqdMjVURGqlR9dK86ZWGOywU0udej bA6TPvr0HqGNtGVqqSrr5eDAr19Og9cecynekfPachRQG8uYXNuDxMBG4wPZBvAHRUQ/ Y/FsKLmprtZ+iPRz557EtIvwGH2ZjvegKAx2yQG93w06yKLG1nlvk5Q0f+QzbvODv40k owKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G5siFWrs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k70-20020a638449000000b0051b423d966csi1234300pgd.280.2023.05.24.00.15.54; Wed, 24 May 2023 00:16:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=G5siFWrs; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239806AbjEXHHF (ORCPT + 99 others); Wed, 24 May 2023 03:07:05 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766758881732966550?= X-GMAIL-MSGID: =?utf-8?q?1766758881732966550?= 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 = next_tick - basemono; if (delta <= (u64)TICK_NSEC) { /*