From patchwork Wed Mar 1 14:17:27 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: 62913 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3658272wrd; Wed, 1 Mar 2023 06:22:22 -0800 (PST) X-Google-Smtp-Source: AK7set92Gxy/gyb9b1qHoUIt6DimJMksrN7+QkwaJpHc+8tofMeoi2kse9v0DMrdb0oQFBURI3aM X-Received: by 2002:a17:907:7244:b0:879:ab3:93d1 with SMTP id ds4-20020a170907724400b008790ab393d1mr9429682ejc.4.1677680542629; Wed, 01 Mar 2023 06:22:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677680542; cv=none; d=google.com; s=arc-20160816; b=OyExELX3Q072Db76I+teLT4DT4pZNdU3mhFlHBcePq8oj9+3uPmAAu6Cu1D9s6AGoe RD+m0e52D2D784owGUtyzJuBrobFZE7UsaoGnhdVVnG/X+KpZNq6QkCqNws3XGyKcu/n y2yE4V+krQUddu84F8Vy/y0eJDVVxUWz8FtsgOPNOrhZNVRAjcMFfYGYUShjPU24fYnB UE+1NLZ38Rq2ucNh6ul34pR7gFFd3RZF9lg+L1W8Q+FaVlXYUI8D3dPzQHNciljzyuEc af26nMlH7Yte/Ze+Z3Uf4wpgs32C9MMsRc01H2BDB3tJBddiITORFVZZM+CWGFSGKCP8 EabQ== 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=BOCDJ0nGoVQscn5FVoqed4VCDME+xrNe/Iu7/rdK+w0=; b=zeqQQZMWFO131BS902RHwgk9rvKQGZvnY8KqnEd98Jo8/iiLfq6BEpoYo5z4k7kpGP UhKTXGbOtFe1ElOB2h/F97vERiqtvEgdqfTvve7c7hRgwUIbY9/lxugYaxv4kIqPTr+Z V+LsEonvVD7gEUnsVS0zVF4kTVHy2YoXkmMW1IiXFR89hJ4sR7fqmYBgNFodtt2c5g0l wZVBLsO5HZ7FLOPJtzpJarfAYY5NnZZbUIBuHJSkNjr/lqqvRP/4+9TqC4FV7bmTUmpM 5z5QQs19UtdCx4XUkeEnm/nCoTDfnH8CRcd6cAFWocGUrBGOVcF7A9a0C1HwtXljw8EL RyuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=vVYQJSb9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=z4koYsck; 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 la18-20020a170906ad9200b008b17dfa77fdsi6186426ejb.127.2023.03.01.06.22.00; Wed, 01 Mar 2023 06:22:22 -0800 (PST) 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=vVYQJSb9; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=z4koYsck; 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 S230074AbjCAOSN (ORCPT + 99 others); Wed, 1 Mar 2023 09:18:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37942 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229823AbjCAOSG (ORCPT ); Wed, 1 Mar 2023 09:18:06 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06DBE241E9 for ; Wed, 1 Mar 2023 06:18:04 -0800 (PST) From: Anna-Maria Behnsen DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1677680282; 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=BOCDJ0nGoVQscn5FVoqed4VCDME+xrNe/Iu7/rdK+w0=; b=vVYQJSb9yVianAUa97TQoewFr+qTYrLwvmDerfNVM54QBpb6Asw+XvHxhSxUyuG8zUS4/8 2ILd7xEeSICxqzuQAROg2Pd+xnjftEkTW4yjSBmrHwQVUYhMVdIISb/rxGn9kmN9OsSvE3 t93Hklqifm0acmfPUhdOiheIyDSNxfWS1pbfDkC9EtHzk5SmwfTFv3eGk88siM1YhA1zEp 1cRCrf6fYJbmj9JrMog1nRWsZYga0avUVdi2KUD6ulMUe5eh3IOfjb9kY3jWTWPRDLml9C ExGMz8hthVqwPS3LA5h5r7l8pnn2SzEtgOeL+iSxJIXg7bjKL1zvEZR2F5oFUw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1677680282; 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=BOCDJ0nGoVQscn5FVoqed4VCDME+xrNe/Iu7/rdK+w0=; b=z4koYsck+hd+4bABjdVaOyloe9V3/a0wwqXl5oOBDAzih9YRhwXlbBqREIzjgDc6HjydLP Qx+i7ASmmkRCAZCA== 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 , Anna-Maria Behnsen , Frederic Weisbecker Subject: [PATCH v5 01/18] tick-sched: Warn when next tick seems to be in the past Date: Wed, 1 Mar 2023 15:17:27 +0100 Message-Id: <20230301141744.16063-2-anna-maria@linutronix.de> In-Reply-To: <20230301141744.16063-1-anna-maria@linutronix.de> References: <20230301141744.16063-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 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?1759175552761275168?= X-GMAIL-MSGID: =?utf-8?q?1759175552761275168?= 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 b0e3c9205946..7ffdc7ba19b4 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -826,6 +826,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) { /*