From patchwork Sun Feb 25 22:55:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Frederic Weisbecker X-Patchwork-Id: 206142 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1770846dyb; Sun, 25 Feb 2024 14:58:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUKAYTfk6Ao73wDrMF0O64D8kG2ya3q5ok5vZTuwJL2RGLoLUOzrGJmHUEeCnM2plwaSSmhYlGfysTJrmjPjHYlzqhCKw== X-Google-Smtp-Source: AGHT+IGZlG8015jbhblPJ4knz4zVwGbosS9nzh6TsHLkm/ScI3HxjEmg/0K/6OJLOeHIzzauXiP2 X-Received: by 2002:a17:903:2595:b0:1d9:b8bc:fd7 with SMTP id jb21-20020a170903259500b001d9b8bc0fd7mr4717183plb.68.1708901933219; Sun, 25 Feb 2024 14:58:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708901933; cv=pass; d=google.com; s=arc-20160816; b=jJM3Blf0XRGmouas+HrRHUd5jUa8JfmGVmBik+AG+3Bb0MyuJy+wsdlqFYE8zo/fRz vKl/JlPVaPRZ/gbH/T4D4boSN/GtBab+XuZyVWNN3V7guTjuecCcpGZlIljkScvgTNKq gXRf/cEG8jK6UBriUMawh2HO4o1duPl7EX8n3tziCZ1AW/O4JG88KyqEq0/0/LI0s726 RONE7scwMyMfJRz2HeX8sAXoEz0uF7FNTROYcZwqGYdSTosSCeqzac9UEJ68qJksNl6C otCwWFghSx/MNg8OZvqBrxtH+6FZvZumC/S0mLp0YcIGaSuxJ4SOlg6RUvId9CE+p9DD pmDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BIcnpcaN/mY8ENBlVtcNMfqugFzFKDu5N+5HdWJLzRA=; fh=9AYDxpIF3ws21qQDvjghHSFUuXpDdpq2Zh/SbnasVRo=; b=OahdV4YW3hQnyPrhuOA75XjoGPf/t8wrkzFz0M80eIg6NySduNK8FV3vDehbGMS8og ZZBteon2YcaOPfwxwcZN5eMTg4bRNAlnf+D3c2HVkfZn7/CxMwfWE7VAZzEE+6qJKYya v97xLAzZhqFGnz1mW1c/UzJYgC4fx5DxZ9/LXnvHTEcj0bpDhmYDuZX+e4LgLkKQXkgd s3CqRpo+9ItX6KBMEq56G6DpyJzDlHQTLT4Y9GvuNWifvrh5EZCdsqMtL0tS37b2MI8v XxU/cyfrJclqy9TRkIuIcLzKK+zscdrew/uwFXtGGMhroaQs/eML5JSgZ1/gvcDY3X8n mOcQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cw9SWUL6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80343-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80343-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id h13-20020a170902680d00b001dc5e90b4f5si2668098plk.592.2024.02.25.14.58.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 14:58:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80343-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cw9SWUL6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-80343-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80343-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 2D45BB20F2D for ; Sun, 25 Feb 2024 22:58:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33C244E1C4; Sun, 25 Feb 2024 22:55:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cw9SWUL6" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 734774D5A0 for ; Sun, 25 Feb 2024 22:55:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708901748; cv=none; b=iDkVeZ9+7wOXfn5htAQJ0FyqVPpDI3cxVWre7TTFp6OSBJxTaG859K5dLFIoG5NK3aiFT+p10n+2icgd0rif4pk5MyNovtQzCpy6PcjrQ3HnGNpZ92b6deyNBghrgU59hW+gdNhBED4vDpAAMfWH/S4vky6UNcUlhlOGBQb1Ry0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708901748; c=relaxed/simple; bh=0ATute8e6VvAt1imtugny66nHYVAoAroOYlbqbrp6NU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VxScetmMguGjvpK9X/qYoyZAKdnf1tGgqfWz18luJRpTLcmr9BC87ehPtH4JaQii4KOwcSO65XhyHwhI6jNW9sw0+DU69RQXhx+lCsD9zVSBaEiF3qV5JE81RXB1O1BjWlYlpOLld+iWrv3MkmjwgQHu8Rq5c4iz8wc6QRux9Bc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cw9SWUL6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C3464C433C7; Sun, 25 Feb 2024 22:55:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708901748; bh=0ATute8e6VvAt1imtugny66nHYVAoAroOYlbqbrp6NU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cw9SWUL6v04yVpISlBEFC9hi2sYD4jXHK2xhyoCpkpTQRnH6PeLXCklz1EHkjIWnF A4ponYwyRyvgHO6QC6mNhM8Q9dYaG7Y5IIy8S/ONqx1ZRfMTgZ/lsY20XuwtxwmEJ2 APKhijkKfHuKi9v5wdx2UEJJ0pcQPVrM6wI7vAWpWUodHhEhqd7hwJeZhX43lS8Nvw kjAUkPsPo6pv1gu/4oX+YEBudLrQXxjAJAg5SIpVJErUW7Cgq3kVHSsqi0wmgmlw8c f3HAbhIhyxsN2KhsHhPQvv+BTGqn7GOaNK38kLt8IUJG9k6O8HLU5Ko9GGMctZBSwE XJw7x/bECQ5tQ== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Thomas Gleixner , Ingo Molnar , Anna-Maria Behnsen , Peng Liu , Joel Fernandes Subject: [PATCH 16/16] timers: Assert no next dyntick timer look-up while CPU is offline Date: Sun, 25 Feb 2024 23:55:08 +0100 Message-ID: <20240225225508.11587-17-frederic@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240225225508.11587-1-frederic@kernel.org> References: <20240225225508.11587-1-frederic@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791913553784527599 X-GMAIL-MSGID: 1791913553784527599 The next timer (re-)evaluation, with the purpose of entering/updating the dyntick mode, can happen from 3 sites and none of them are relevant while the CPU is offline: 1) The idle loop: a) From the quick check helping the cpuidle governor to heuristically predict the best C-state. b) While stopping the tick. But if the CPU is offline, the tick has been cancelled and there is consequently no need to further stop the tick. 2) Remote expiry: when a CPU remotely expires global timers on behalf of another CPU, the latter target's next timer is re-evaluated afterwards. However remote expîry doesn't happen on offline CPUs. 3) IRQ exit: on nohz_full mode, the tick is (re-)evaluated on IRQ exit. But full dynticks is disabled on offline CPUs. Therefore it is safe to assume that no next dyntick timer lookup can be performed on offline CPUs. Assert this expectation to report any surprise. Signed-off-by: Frederic Weisbecker --- kernel/time/timer.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/time/timer.c b/kernel/time/timer.c index 4f4930da6448..e69e75d3858c 100644 --- a/kernel/time/timer.c +++ b/kernel/time/timer.c @@ -2233,10 +2233,10 @@ static inline u64 __get_next_timer_interrupt(unsigned long basej, u64 basem, bool idle_is_possible; /* - * Pretend that there is no timer pending if the cpu is offline. - * Possible pending timers will be migrated later to an active cpu. + * When the CPU is offline, the tick is cancelled and nothing is supposed + * to try to stop it. */ - if (cpu_is_offline(smp_processor_id())) { + if (WARN_ON_ONCE(cpu_is_offline(smp_processor_id()))) { if (idle) *idle = true; return tevt.local;