From patchwork Wed Dec 20 15:59:11 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: 181716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:24d3:b0:fb:cd0c:d3e with SMTP id r19csp2741787dyi; Wed, 20 Dec 2023 08:03:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG7uxnMFjwA/uzu22QJOWqJ0V55ArxJphsP6wDwYW5rcjNog7fax7F1ujXez9k2vyGPYCz9 X-Received: by 2002:a17:90b:1b07:b0:28b:9081:b54 with SMTP id nu7-20020a17090b1b0700b0028b90810b54mr2979710pjb.90.1703088184283; Wed, 20 Dec 2023 08:03:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703088184; cv=none; d=google.com; s=arc-20160816; b=Ob+SkzQFO/r4aW0rquZvJXRUHBzaFuTEuuVvv/h5a4xb3PrHD0cg3CNPLfsqH1pZyf n0INi4SrEpgp+W2cLAT/rRV0wdjc1IfctanrWPTMv/rt5f6Se0ZfhIgQkU28Es6sJeY3 bIh9ck6tuhgdXbA0ckov49426hz6BJJDjJIlYjeF0h1BH5dicNMqmj8wm2ZULILKsK21 FJ/VVOUjRZyNTQSJfwrNO000Fq/LI3MJiJQ1HXvz7rvJPO7LxykJ+iz2QbFSJW9jgHsV /GQOabgsotvJ2VfURvXElmp+tnhw8X0KYmX2PmW2XpvuNLgJZJxQzDXAE1lgID6/ygry 5FPQ== 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=RzybjEgY0lRz1tGpPCvCLZ+wsNlqMcfDI3U2j+gJiwY=; fh=IdquJyaazQ3wXWxdOExnpctJRLX4Jw3HEb/tnyKonzY=; b=UD1Yj6RsD+sA61MS56naV8Y1w3otxTZJUgJLIAmMjB2GlTuOfWof96dZJZv+xpbh6L 4orTntu8opyu1wtgs7P9K3b0bPN0/JI6wdhJDSQV0UB83Q3rLnTMUc+HlKQ0pNB003KU JRYmQj4gcaGaP3o/mmlxFETe/MQ3T0VByo7XQAPaFNOQqX0lfif1gQyE8D6pS7/hrgNt aJ3vcSreUui+YTQXYGXmu2/Iksl4ynUbS4hbJWY7WA6WqBGZv2dH0shL5p/KaVcmZtvy R7/MGDOpm7+xxxzTJmLpQINW4Cft2dd48dRGY5UcqXjlmCNNhSBKEZ2o2WV9wIYAJ5V0 0W7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AdSucZPb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7233-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7233-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id hv9-20020a17090ae40900b0028b48258ca7si3167831pjb.178.2023.12.20.08.03.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 08:03:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-7233-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AdSucZPb; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel+bounces-7233-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-7233-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B31AD281E81 for ; Wed, 20 Dec 2023 16:03:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9977C4B5A2; Wed, 20 Dec 2023 15:59:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="AdSucZPb"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="kg/bqHr1" 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 96499495D6; Wed, 20 Dec 2023 15:59:13 +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:11 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703087952; 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=RzybjEgY0lRz1tGpPCvCLZ+wsNlqMcfDI3U2j+gJiwY=; b=AdSucZPbmAtcbxh0qJc7JU/BWsQff3T1mvrbRjugXE7UR0NSUWlBoueKEnJ7cDLgqaMG4n sToEavjZbFvg/tGQDO8tWL20+KLvAYsIz/0LhOCBqgFjnOpzIlkQFGNggNR4t7hRvafC48 qm4j8FQLAzYA3GTb7xXaCbgJDAJY9g7+OJdZxribj7tzN2gM8EQ0N3h5m8Jqx9TSPVnxLC +qrMqlFAd1KP+QCZz379UNpPPNiauh8xd4N6X6sUG9Z8drOFPrIIa6rhe1XO+WrI8TwDap 02wd/tWupz+hxE1/dVs3L49TVJDtqJ7mrWmfMFXGx0Kof9bJ0I9wZhsDX49t9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703087952; 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=RzybjEgY0lRz1tGpPCvCLZ+wsNlqMcfDI3U2j+gJiwY=; b=kg/bqHr1m9Z3vQh8d5WASGyOKxW/4CSjWp1VJ29zulnC8dKmbLUV69CnCbKXyxmQnL/jZ5 3VLb2LBHjT8rj5DA== 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] tick-sched: Warn when next tick seems to be in the past Cc: "Anna-Maria Behnsen" , Thomas Gleixner , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20231201092654.34614-4-anna-maria@linutronix.de> References: <20231201092654.34614-4-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: <170308795125.398.1424176018413782016.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: 1784071161290723538 X-GMAIL-MSGID: 1785817395803606716 The following commit has been merged into the timers/core branch of tip: Commit-ID: cbf04a22026100dceeceec67fcbf1973383eb32f Gitweb: https://git.kernel.org/tip/cbf04a22026100dceeceec67fcbf1973383eb32f Author: Anna-Maria Behnsen AuthorDate: Fri, 01 Dec 2023 10:26:25 +01:00 Committer: Thomas Gleixner CommitterDate: Wed, 20 Dec 2023 16:49:38 +01:00 tick-sched: Warn when next tick seems to be in the past 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. To prevent complete misbehaviour, also reset next_tick to basemono in this case. Signed-off-by: Anna-Maria Behnsen Signed-off-by: Thomas Gleixner Reviewed-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20231201092654.34614-4-anna-maria@linutronix.de --- kernel/time/tick-sched.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/time/tick-sched.c b/kernel/time/tick-sched.c index fce3c6f..a17d260 100644 --- a/kernel/time/tick-sched.c +++ b/kernel/time/tick-sched.c @@ -839,6 +839,10 @@ static ktime_t tick_nohz_next_event(struct tick_sched *ts, int cpu) ts->next_timer = next_tick; } + /* Make sure next_tick is never before basemono! */ + if (WARN_ON_ONCE(basemono > next_tick)) + next_tick = basemono; + /* * If the tick is due in the next period, keep it ticking or * force prod the timer.