Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1006493rbb; Sun, 25 Feb 2024 14:58:39 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXw/qYB66l4Ol5T32jLTz0S4pRtt84/cIr/bMxwySMmhvAnil3Yq9Q9o2OkA4NWAAIpSvbtsAJmFd6NrbsJnB7UuooXO3x70w0HIhSg5A== X-Google-Smtp-Source: AGHT+IG1g/68JCNibVrteua2gq4chY5r57VIQAc1Whwzl9vaSCXq0vgHkb6L1TRHMQp8wWyYIXS/ X-Received: by 2002:a05:620a:28d3:b0:787:d4ed:7e36 with SMTP id l19-20020a05620a28d300b00787d4ed7e36mr563958qkp.67.1708901919570; Sun, 25 Feb 2024 14:58:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708901919; cv=pass; d=google.com; s=arc-20160816; b=K6/5WNYMj0U8K6Gxi0RrRpVTTk4wwgot9qPfHBSJEjAN1chuynjpRBBSbnkEWf1Vvg ADBkh5+nu2Izr3KXFoTDeZWCuPSDOxEj/hIDznnNpY3DEHRpSOLqTEvdSsyYCTphPUCf MpMBUBL8cE0qgZo7TNOF7SwdyxtrrkfkN3AbzmQqn47xaw5TE3FGtnF+eeaIZINGl3xX SGV8Bp7fl6G96ScGcURGw312s0MkNn8IISWVnE09vLVzJQ2Xt7/EBF8oq9K6qd5vi0Ew YWhOHTvJLM0cFd/dmrGAVQ6yOyt95mJY9FrugcC41P6+BvjCgK4qDv/XXaIo3RHdL2x1 Xmtw== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80343-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id wa17-20020a05620a4d1100b00787bd7195a1si3850535qkn.424.2024.02.25.14.58.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 14:58:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80343-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80343-linux.lists.archive=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 533D01C21374 for ; Sun, 25 Feb 2024 22:58:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 462664D9EF; Sun, 25 Feb 2024 22:55:49 +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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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; -- 2.43.0