From patchwork Fri Jan 13 12:31:15 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: 43266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp244646wrt; Fri, 13 Jan 2023 04:38:41 -0800 (PST) X-Google-Smtp-Source: AMrXdXshe3BeSNh+0grZTTw4SRhkd/nlnTrBoPYPMKkpGOXZLrUW70tzUhDeD2gAyQYceXy14n91 X-Received: by 2002:a05:6402:299b:b0:499:70a8:f91a with SMTP id eq27-20020a056402299b00b0049970a8f91amr17497996edb.19.1673613521090; Fri, 13 Jan 2023 04:38:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673613521; cv=none; d=google.com; s=arc-20160816; b=U4MSSFMoxPd8TOK+0nRsr+ljdMGr5wZcBAvTIRwVZxA1clJJxooKT+y2s+eXSwj1vm 0lQ+Xz4T5ajdpSI4wWhEEtX7bW3RnOOd8LHiA9lSA1NEcv66BUjoJUk4hlutHxOXZUWa mX59zpaGEVekywBYYLOPzbp/31VpzC1VwoMdId7iACAXVbdRkG6mVbrgVl4vXmEi45iV 99SYvxulUsuySOGF2o4JztIFCLOIbJiw2gUvgGqbImooosdBXvw7ikvmuRz/nnl39w+L mF71SaESppkxk8RrgPJ/451MJfBndzIc09+RtqMO2+Fhv2sBIeP5sOEOOVdazH3Zp+hh V/9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=YW2sfM223RFduoyW0Y9JWEHQpYsrHXUWc4evcmthhwA=; b=yQh+hhYfEsuVvWzg91D4UhDGU3O6ReDumk59hfku/mhAXsozVXPTbQ7DybbltAl76h jHoLneml3waKH836M1K/N9Y+ySY8+BVW1ndUZ2OxBbjrbSIoYNNUjDCFM0HH5nOVMV3f zMR1FuZkWjv4uXvu5hnEgKEyMw+gNSir+sQ8OosQCAxS2P9JlYzefh0oDajWJObnTQBO RlKi9/dz9QA9efQV4M/3L7ZuxkL3fARlgaBUMg+pXHm60V1KRycwYBS+LlUo53vvWlaN IqwOYAjPhFm09ZluYiIGW51s6Zyui7bbQlNeEOKayK+vDDJsZkZxBOgSH1vTJ7csqXJh Jp1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=YcmdbJXf; dkim=neutral (no key) header.i=@linutronix.de; 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 b7-20020a056402278700b0046dd7c3ceb5si22744631ede.475.2023.01.13.04.38.16; Fri, 13 Jan 2023 04:38:41 -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=YcmdbJXf; dkim=neutral (no key) header.i=@linutronix.de; 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 S233019AbjAMMhT (ORCPT + 99 others); Fri, 13 Jan 2023 07:37:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240363AbjAMMcV (ORCPT ); Fri, 13 Jan 2023 07:32:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0140574DF; Fri, 13 Jan 2023 04:31:17 -0800 (PST) Date: Fri, 13 Jan 2023 12:31:15 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1673613076; 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=YW2sfM223RFduoyW0Y9JWEHQpYsrHXUWc4evcmthhwA=; b=YcmdbJXfoNvsyM+4z871cJczKTXprx/LRAvXUmNBm5l4MIbzFnIyEN2qVl+wkUtxNgShsd m+8ID/uZP19j363cmhmrAMZOLCp/jGZtMyHlexkdKgsnxyzecEkkkbB6P7jJyAiZaFrLeW nrx5zjtjcDOLjtaimAe2ftp+fSCCMXl1jWt4hVwrnHoS/eLJMjjQgcLz/7JzY2vAITLdFz 1ghh7Oi0kzLgM5V4lb42/01j0TS+DNHmBRVMl79JL8BpkOnooU5+9SX0jieus7KhcJyBln vr5PKWoCmoYJhg/UOna6J+gxgrY4vc6u00VhHrT/JwFpNHJ8Od42vfqV5Z7crA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1673613076; 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=YW2sfM223RFduoyW0Y9JWEHQpYsrHXUWc4evcmthhwA=; b=cr/jWBn+lv+PuzHVgpUlaHL7J0Bz8awjMJZrbZnUP70BH+krDp/r5PALSIvgARX7GysgBj aitNlI8yx+tHWSDQ== From: "tip-bot2 for Peter Zijlstra" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: sched/core] cpuidle: Move IRQ state validation Cc: "Peter Zijlstra (Intel)" , Ingo Molnar , Tony Lindgren , Ulf Hansson , "Rafael J. Wysocki" , Frederic Weisbecker , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230112195539.576412812@infradead.org> References: <20230112195539.576412812@infradead.org> MIME-Version: 1.0 Message-ID: <167361307533.4906.17168244986625379604.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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?1754848476213070408?= X-GMAIL-MSGID: =?utf-8?q?1754910971577586590?= The following commit has been merged into the sched/core branch of tip: Commit-ID: bb7b11258561e47abbacebf76e3ce4092953dfdf Gitweb: https://git.kernel.org/tip/bb7b11258561e47abbacebf76e3ce4092953dfdf Author: Peter Zijlstra AuthorDate: Thu, 12 Jan 2023 20:43:18 +01:00 Committer: Ingo Molnar CommitterDate: Fri, 13 Jan 2023 11:03:22 +01:00 cpuidle: Move IRQ state validation Make cpuidle_enter_state() consistent with the s2idle variant and verify ->enter() always returns with interrupts disabled. Signed-off-by: Peter Zijlstra (Intel) Signed-off-by: Ingo Molnar Tested-by: Tony Lindgren Tested-by: Ulf Hansson Acked-by: Rafael J. Wysocki Acked-by: Frederic Weisbecker Link: https://lore.kernel.org/r/20230112195539.576412812@infradead.org --- drivers/cpuidle/cpuidle.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 6eceb19..95c801f 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -236,7 +236,11 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, stop_critical_timings(); if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) ct_idle_enter(); + entered_state = target_state->enter(dev, drv, index); + if (WARN_ONCE(!irqs_disabled(), "%ps leaked IRQ state", target_state->enter)) + raw_local_irq_disable(); + if (!(target_state->flags & CPUIDLE_FLAG_RCU_IDLE)) ct_idle_exit(); start_critical_timings(); @@ -248,12 +252,8 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, /* The cpu is no longer idle or about to enter idle. */ sched_idle_set_state(NULL); - if (broadcast) { - if (WARN_ON_ONCE(!irqs_disabled())) - local_irq_disable(); - + if (broadcast) tick_broadcast_exit(); - } if (!cpuidle_state_is_coupled(drv, index)) local_irq_enable();