Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp1127895rdg; Fri, 11 Aug 2023 10:31:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIuLOR2Z8neQBJzsKpk3ou41xLt95GB0oAJkY8DWDmtA8k7YbMJR8jGafDjTvz3+b0L0Ub X-Received: by 2002:a2e:320d:0:b0:2b9:6871:e989 with SMTP id y13-20020a2e320d000000b002b96871e989mr2154863ljy.19.1691775116680; Fri, 11 Aug 2023 10:31:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691775116; cv=none; d=google.com; s=arc-20160816; b=Yr52KGj9FX/e7dDpl9OM5STD7Cf/r0p2FcSi5NibXHULKzjOH4YUp6U7pfjZOEcA6/ 1CJZTyY9ZIc28R+I1Rnxar7rqy2zrCv7S54hNGHJ6FnuNrJZZ4FpY9iTSa6ruZRw24K2 6EwkeYJ1toMNMYR4zaRCiZJcwiynmXKgbR7ZRPI8GcxdR0CMU0o7G9dpjgKuWgkEdikP jASm96Lu87iDjIdoFblW+VJ2fJLMJwsX6vymKo+Q1l8H67H+lhGOKlAl0vv6lgYKovgI xbsOHoYIgb2CDy5hCu520pbgYksW+piASG7qe2QQeQG2o8Mx62a+8MjlSwy85Rv4Q9fh IaOA== 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:from :dkim-signature; bh=plAoRAaaCikEqv+dvKpupAjBzbsBq5twhjRvREEYPGo=; fh=K1m6n+brToPLMsYko3rtXKxC+lCostu9M84onRqB7cU=; b=fDrfs+Af7I5QTAMtTR4bX7/YNDXjJ6qOJiF/0/MXo9DkeL+Nk8zb/PmQpXguDqWI1N gjZ5b9uifKCKdq5tTGDlHGXXmf/MBPDSOnRL04r4jY0Xo2gv4/b7Qp9xtm4XXzyxeTvf iYHus7FYvxPcsZRz9q5MRe5hmt9P40oJijQfDO95Kj2uuaMcHeoBs8nvXIdW5pYDgOGT eMY2tY/SiSs+YXqTCXEfh/X+yjQ+ir+XPQdOr8UIdqELxQv78lSGupSMDbxPjVZTWSNK kZAWMU6eE0FRBwNWWEFRDLBeGwrE3l3JXOJc0FeKaxqvoKn8hPe5KvKNPM/QZ/w0Qb+u MTiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="cMAuv/uU"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170906060b00b0099bd1a98ad5si3655678ejb.734.2023.08.11.10.31.31; Fri, 11 Aug 2023 10:31:56 -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=@kernel.org header.s=k20201202 header.b="cMAuv/uU"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236228AbjHKRBR (ORCPT + 99 others); Fri, 11 Aug 2023 13:01:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235983AbjHKRBL (ORCPT ); Fri, 11 Aug 2023 13:01:11 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D88DB30E7 for ; Fri, 11 Aug 2023 10:01:02 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 6E25D67684 for ; Fri, 11 Aug 2023 17:01:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46D28C433C8; Fri, 11 Aug 2023 17:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691773261; bh=YaoIKYC/HMtW27OOcRlg0CgBQJS8nCnjs/a8mtWVN9k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cMAuv/uUk1D/ks5Q4Tofx42uo+5BObOOtWMdaGvK9vFT2YixjWvjrwrhxmNgits1L 9O8X6v6ubtlin/ESJ/BraO1nBxVuVsD5GIDnmrr+ywXDcsVpxMsTcEjIt7XK/dICL9 /aNDYUXTHwGSLFkS3TEVydJPQWPG8aVYtIjZzR0TIaqcGYjfHCmcr3QIukV9ex873X rfZUX0OBrxoHoGN/gEOO6i9z/5JMiLh3sHiQlyte7T7u2xlvf/WhrLbB46Tx32q/MC kTN+EESC255qjJDAseDUBchyqbkz3+tdE2pALmTWWLxow57Ebe42t2PCdyGilblR05 dNZHqH95bTnNw== From: Frederic Weisbecker To: LKML Cc: Frederic Weisbecker , Peter Zijlstra , "Rafael J . Wysocki" , Daniel Lezcano , Thomas Gleixner , Anna-Maria Behnsen Subject: [PATCH 03/10] cpuidle: Report illegal tick stopped while polling Date: Fri, 11 Aug 2023 19:00:42 +0200 Message-Id: <20230811170049.308866-4-frederic@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230811170049.308866-1-frederic@kernel.org> References: <20230811170049.308866-1-frederic@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,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 poll_idle() can't be called while the tick is stopped because it enables interrupts and only polls on TIF_NEED_RESCHED, which doesn't tell if an interrupt queues a timer that would require a tick re-programming. There is no point anyway to poll with the tick stopped so add a check to make sure it never happens. Signed-off-by: Frederic Weisbecker --- drivers/cpuidle/poll_state.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/cpuidle/poll_state.c b/drivers/cpuidle/poll_state.c index 9b6d90a72601..009f46f121ae 100644 --- a/drivers/cpuidle/poll_state.c +++ b/drivers/cpuidle/poll_state.c @@ -7,6 +7,7 @@ #include #include #include +#include #define POLL_IDLE_RELAX_COUNT 200 @@ -19,6 +20,13 @@ static int __cpuidle poll_idle(struct cpuidle_device *dev, dev->poll_time_limit = false; + /* + * This re-enables IRQs and only polls on TIF_NEED_RESCHED. + * A timer queued by an interrupt here may go unnoticed if + * the tick is stopped. + */ + WARN_ON_ONCE(tick_nohz_tick_stopped()); + raw_local_irq_enable(); if (!current_set_polling_and_test()) { unsigned int loop_count = 0; -- 2.34.1