From patchwork Thu Mar 16 07:47:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kazuki Hashimoto X-Patchwork-Id: 70624 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp349525wrt; Thu, 16 Mar 2023 01:12:41 -0700 (PDT) X-Google-Smtp-Source: AK7set+JHYBIagzv/XX75zMkQ6yiQ8kfe0k2GEDvALauR8taxlEMlk+LBZJnD00gaTLakD9Fk0tU X-Received: by 2002:a17:902:f1cc:b0:19f:3234:fec5 with SMTP id e12-20020a170902f1cc00b0019f3234fec5mr1928540plc.51.1678954360770; Thu, 16 Mar 2023 01:12:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678954360; cv=none; d=google.com; s=arc-20160816; b=yEXV9hSP/ocY43/md+Ho7p7sJonlfFiMmBrN7hQNmQK51R45Jw/9eWdTVG/LKYSfPy NLd9t4g6t2j8mlbefUPOVnTnBAXgdyG4sO2B/eoaAZTuIWjtTd1TxSCqxL5FBtHZ3QL7 /jj2UshyzBR0an4Wfp85osHabqQNSr9ZKgr2d0geG5zQfH3ueLp6Rbc1/hre1dp9uaKS fucFggvkDtqRkLayvmXCt4COk3va5EEy+CQCxsN5DlJGZzVMY47gocAYEw6uVgxkRTg5 bWXAUFpLFVd8lgfKeS5oefCqzN2jWrz4fsayEpLU/vKKHcCp+SQG42BFsI4TfKGuEE8I df9g== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=oLMa64tOXtUboutgw3wHxnPNOyffSqKsOl76z8VN4uM=; b=C4RvgvW12kzXADUaP6oPr9wqXwt5wYlXhkhbu7jGiugCWNohm4h+LyEzm3jA63HK9M UFxNXtIYDET1kbUZ4iWNZv70X4FJnZxfP9vRt/ZGH4o510nHRMNcwGYMFsgkPagWl48j isSDMEZPF+z2fhn05+GlKgF1rKc2Z1upNafXosha1ZUSn4N6koXN9z4l4ygOg2vnA5P2 mKS4evageP8SBH0vzFiPHTV4/vBgjv3RHcU8F5Va5GDRG0K1FSfYsuSiUXEiDiOzjQ9H r1lN88XHKDqw7vA5+lz5ukugxlK1Zb61M3iSdS3R83e/2UwxjDTkgEoSUYanrTPMiTcA dJrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b="J0ql/N1j"; 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=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o17-20020a170902d4d100b001a17a0e9b73si4147100plg.425.2023.03.16.01.12.28; Thu, 16 Mar 2023 01:12:40 -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=@gmail.com header.s=20210112 header.b="J0ql/N1j"; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230179AbjCPHtK (ORCPT + 99 others); Thu, 16 Mar 2023 03:49:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229769AbjCPHtG (ORCPT ); Thu, 16 Mar 2023 03:49:06 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2A11ACB97; Thu, 16 Mar 2023 00:48:58 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id q14so582704pfu.7; Thu, 16 Mar 2023 00:48:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678952938; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=oLMa64tOXtUboutgw3wHxnPNOyffSqKsOl76z8VN4uM=; b=J0ql/N1jcwlIxs0v4upjzjqWI9WyFNnSNdhb/rr9WNzDVNCb7oNR5OIwrojCrc2eiO 6w3TW5pPhH3qqpsXcnKeTrnpGJ/WTvdbiASknR7wm+FhEt0WuElaQH9Fx5BaLu6oCf4n S/8de6hBBp36SkSyvgl5DFe756pYWcvhJYPaA9p9l8+JMrEqPjlTNjMWTBDV2xvGYEZO 9Fwjd9CGiGmBWNLv85LcdrEt3+h8zQzTOehZDn/iL2GmCw+u1zfikTyPzySvqMKBUnPR a4ZlaKEUYxs0/+rzG2JhsPqOCrdEy9D0aII40aH4XchQyMPYYJy7I3nNuB9R7ftFj6e3 vU/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678952938; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=oLMa64tOXtUboutgw3wHxnPNOyffSqKsOl76z8VN4uM=; b=aG6DCxtl4qT1zwh72eshLWIz9vhFgyjh1T+HQW3guXYDg0dRUG9izUXB0BoLJH0lTA 43T2+D176Ox29gfwZvNdy4cRylEVrCGd1/kGtg2/ULER5BNDS1/BlWftbBEl76YG7flQ 1wBsSphgKCueN7b/b6Qa29kfH9WXwqjlnS9/xNeklJRV+YjqjuudyDIArm5itL4WVbQg el7EUX6j8SVG98NNVdUk7u0ooU9tTHq/BDmDR4GjupCzwLFny7zk6KfTb1bWCWvmnrl2 Dbfm2YQMLLcTxCx3Z0sf4QrKBezrnHX3Yb3H1ArrE5ibgVNfjZO32C5BwzqfK+c1umeY L+aw== X-Gm-Message-State: AO0yUKUBy13hH1M0SDvV/JkNmdmsFU8nwNhMR8dMeyQgvJ4DLjRvPDtS FQTq13Em3tW9gZ0N2BCfn+EjKArRfc/u4Q== X-Received: by 2002:aa7:96b0:0:b0:624:a58a:d28 with SMTP id g16-20020aa796b0000000b00624a58a0d28mr2234103pfk.4.1678952938362; Thu, 16 Mar 2023 00:48:58 -0700 (PDT) Received: from kazuki-mac.lan ([2400:4051:ea3:5910::789]) by smtp.gmail.com with ESMTPSA id 23-20020aa79217000000b005e099d7c30bsm4683618pfo.205.2023.03.16.00.48.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 00:48:58 -0700 (PDT) From: Kazuki H To: linux-pm@vger.kernel.org Cc: Hector Martin , Sven Peter , Kazuki H , "Rafael J. Wysocki" , Daniel Lezcano , Pavel Machek , Len Brown , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH 1/3] sched/idle: Remove stale comments Date: Thu, 16 Mar 2023 16:47:48 +0900 Message-Id: <20230316074750.289025-1-kazukih0205@gmail.com> X-Mailer: git-send-email 2.40.0 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1760511247395193451?= X-GMAIL-MSGID: =?utf-8?q?1760511247395193451?= rcu_idle_enter/exit() got removed in commit 1098582a0f6c ("sched,idle,rcu: Push rcu_idle deeper into the idle path"), so this comment is outdated. Remove it. Signed-off-by: Kazuki H --- kernel/sched/idle.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index f26ab2675f7d..dbfc2eb5ccbd 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -179,12 +179,6 @@ static void cpuidle_idle_call(void) return; } - /* - * The RCU framework needs to be told that we are entering an idle - * section, so no more rcu read side critical sections and one more - * step to the grace period - */ - if (cpuidle_not_available(drv, dev)) { tick_nohz_idle_stop_tick(); From patchwork Thu Mar 16 07:47:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kazuki Hashimoto X-Patchwork-Id: 70621 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp343530wrt; Thu, 16 Mar 2023 00:58:28 -0700 (PDT) X-Google-Smtp-Source: AK7set8woRtpFxDjOGwGK+7vlbLb0t1wFD1aekM8FOZa7QPvqRpG9G+Qg8uLTvdeDjsv95EMEWi7 X-Received: by 2002:a17:90b:3ec8:b0:23d:e0c1:8b8e with SMTP id rm8-20020a17090b3ec800b0023de0c18b8emr2794805pjb.17.1678953508517; Thu, 16 Mar 2023 00:58:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678953508; cv=none; d=google.com; s=arc-20160816; b=lCFy5fbmwrrx71O2XaaEScDdaU8bPMET7weNT+ty/N73WfwxiNE2NrH96wzG4HbXvM EmFl7PMAl0g4w+E8IVzgVdVdWypLFqHXArdSB/8SVam+G/0r/m6OQa0aOAm10oz2nlQR t4fuM54u8odZ22r5aciwiLr4J93ZS9HDoNpcDmm+qCIJpX+PHu6KhsWGi68fsHlgjDI/ StNgGoPiguw2KjM4q6oSZO/6M2X3oBKlb0SG/wC8xO/yW1BdCWACDQsWLXDeUFAEWiFV ZSdnpDJPs/NslgbxRSUmuX3zeaRjMyXcLzBSaxnI47xk4yx7mvssBfgKsTBtKGsJOF2Z 7hgw== 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=Cm9FeMy4GVQb6Y304/sdZ2D3L6nSGw+tgNkZCTPzffM=; b=LTw+pQENQqnwAu8n8OifpidjqLFM91xupc7uf4fzKy4jOStqBjIvR5yQV91U78OEnR bOc355cg8mhc44LzEjinObMPt8kNoWNRwXqBq4DPsSgD9m5MkH9hZWahiRBRhKKwS5y+ BBGzIQ9LEvIkZIMUtSZ9s+uSs+yKsCdgdt9f3XqOZ+zV6mkgu3M0EajUPiUmgVsvC7g6 vCeT0fe0/zM9IO8KvoFki6D6IcTzimJ87RlCQKB+PZGR3G+Eqrpo/yiEf34sp8WRbseC 4zvy9k71uDVJfZeG7HefM2vtYGkbvleJWLqIBtDovTmpP9ZaAbdAGCqS9Xv5+AIDGMir WGQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=h3a0FB3z; 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=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a17090a9bc800b0023f254b442asi1395338pjw.78.2023.03.16.00.58.13; Thu, 16 Mar 2023 00:58:28 -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=@gmail.com header.s=20210112 header.b=h3a0FB3z; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjCPHtO (ORCPT + 99 others); Thu, 16 Mar 2023 03:49:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43904 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230040AbjCPHtJ (ORCPT ); Thu, 16 Mar 2023 03:49:09 -0400 Received: from mail-pf1-x42f.google.com (mail-pf1-x42f.google.com [IPv6:2607:f8b0:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 42CBAA8C62; Thu, 16 Mar 2023 00:49:03 -0700 (PDT) Received: by mail-pf1-x42f.google.com with SMTP id b20so584562pfo.6; Thu, 16 Mar 2023 00:49:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678952943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Cm9FeMy4GVQb6Y304/sdZ2D3L6nSGw+tgNkZCTPzffM=; b=h3a0FB3zEfWLChDCwDTq4NbtUzDTJqXLr2JguGJfZ3NC9rb4PXY++xqU1s/1JYq7IN N85hOfCEM6ikcoY+6Nd9OCwR6nLmZWxBu8uJkhPgpYAESla4/OZPMWBRLjwevEqtqbol LDe0mW/Dt4Z3sjX2k3sCIJccy3VLnjU9qqS3CtGzZqhyqx2iALqCGXMn23q7WQaqU54s mJPpsTkp6TlCGhI4JU5ACu2YQMY6+yUXHQRKASuhnIiJBgz6I++M4HfKd4zHCZxdiLqB bOdfZL18etGM01A2VnoHRUU/WIg7NUtcJLEoeLr5INmST6W4qTj1gGY5sT6UxLzaDiqF jApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678952943; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Cm9FeMy4GVQb6Y304/sdZ2D3L6nSGw+tgNkZCTPzffM=; b=bfO3znq1RSvl6ZtnDpGGm/h8gniQ4DQiZQZdNdGHmgONdNeMdRyQ63eYFyvTbWFh7T 3RJA1Lup9LTgrkuyZQRZz6KAB+bua5Lnas0liwU0+rTK0mEaIzdo5AvD/7o9JbKJYRTt VKTQ94fIEyj2mo4TomiHHqllXvPLEdN9lTn0XdF+BrmR+ELoz/EczSYvFRZ7P/3hYAPk VmWuiqmzMNcs4pZ3JY3bPD9rcVaaocV9AYgwYdGZJmJAscwgbPr3GVIOV+4L9nS1txrM Zhw6s036bSM7l3fqcXOA5HTGOQNNPHFtYcHBKEA7vVNEfoXhXE240ZtUxLRuNkXMUSCt QHOQ== X-Gm-Message-State: AO0yUKURUbaKh1ymL1nsADxB3MxygyP5YCfMNmfe4fu0o7rfZWf18ZnY UNTpTA1aRm0nUUvWOADSv4+8vOzUZA0t1g== X-Received: by 2002:aa7:97a2:0:b0:625:d5b5:1e9d with SMTP id d2-20020aa797a2000000b00625d5b51e9dmr2283432pfq.1.1678952942815; Thu, 16 Mar 2023 00:49:02 -0700 (PDT) Received: from kazuki-mac.lan ([2400:4051:ea3:5910::789]) by smtp.gmail.com with ESMTPSA id 23-20020aa79217000000b005e099d7c30bsm4683618pfo.205.2023.03.16.00.48.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 00:49:02 -0700 (PDT) From: Kazuki H To: linux-pm@vger.kernel.org Cc: Hector Martin , Sven Peter , Kazuki H , "Rafael J. Wysocki" , Daniel Lezcano , Len Brown , Pavel Machek , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH 2/3] cpuidle: Don't pass any values to cpuidle_not_available Date: Thu, 16 Mar 2023 16:47:49 +0900 Message-Id: <20230316074750.289025-2-kazukih0205@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230316074750.289025-1-kazukih0205@gmail.com> References: <20230316074750.289025-1-kazukih0205@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1760510354215187206?= X-GMAIL-MSGID: =?utf-8?q?1760510354215187206?= There's no reason to pass any values to cpuidle_not_available() as the function works standalone. Since we're planning to use the function in other places, make it so to avoid code duplication. Signed-off-by: Kazuki H --- drivers/cpuidle/cpuidle.c | 6 ++++-- include/linux/cpuidle.h | 6 ++---- kernel/sched/idle.c | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 6eceb1988243..cc05acf4d2a8 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -48,9 +48,11 @@ void disable_cpuidle(void) off = 1; } -bool cpuidle_not_available(struct cpuidle_driver *drv, - struct cpuidle_device *dev) +bool cpuidle_not_available(void) { + struct cpuidle_device *dev = cpuidle_get_device(); + struct cpuidle_driver *drv = cpuidle_get_cpu_driver(dev); + return off || !initialized || !drv || !dev || !dev->enabled; } diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h index fce476275e16..11de17924910 100644 --- a/include/linux/cpuidle.h +++ b/include/linux/cpuidle.h @@ -139,8 +139,7 @@ struct cpuidle_driver { #ifdef CONFIG_CPU_IDLE extern void disable_cpuidle(void); -extern bool cpuidle_not_available(struct cpuidle_driver *drv, - struct cpuidle_device *dev); +extern bool cpuidle_not_available(void); extern int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, @@ -174,8 +173,7 @@ static inline struct cpuidle_device *cpuidle_get_device(void) {return __this_cpu_read(cpuidle_devices); } #else static inline void disable_cpuidle(void) { } -static inline bool cpuidle_not_available(struct cpuidle_driver *drv, - struct cpuidle_device *dev) +static inline bool cpuidle_not_available(void) {return true; } static inline int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, bool *stop_tick) diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c index dbfc2eb5ccbd..558a5c987597 100644 --- a/kernel/sched/idle.c +++ b/kernel/sched/idle.c @@ -179,7 +179,7 @@ static void cpuidle_idle_call(void) return; } - if (cpuidle_not_available(drv, dev)) { + if (cpuidle_not_available()) { tick_nohz_idle_stop_tick(); default_idle_call(); From patchwork Thu Mar 16 07:47:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kazuki Hashimoto X-Patchwork-Id: 70629 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:604a:0:0:0:0:0 with SMTP id j10csp350091wrt; Thu, 16 Mar 2023 01:14:17 -0700 (PDT) X-Google-Smtp-Source: AK7set9Xe28Wv024SHpaRtZdviJpgasQb6jYU6XNahAni44wl7OcVlolonVzv/VbJWy47BpomgxG X-Received: by 2002:a17:90b:380d:b0:23c:8ee2:bc14 with SMTP id mq13-20020a17090b380d00b0023c8ee2bc14mr2978034pjb.24.1678954456933; Thu, 16 Mar 2023 01:14:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1678954456; cv=none; d=google.com; s=arc-20160816; b=AAEdFLQD5t76cRrsLXSiDM7D0KYHsKIyLZuE65jOmFnd4VyY2qLaF/i7zMJwckWrf2 VQyUCHYazdpeNlopdgV6YhJ9mUporOK96KmTyNK5EP0MH6xax7tDs9AhyTnonUXHOu1M w/DRtjsb/yqWyOk4WRGb1vXUOAwX5hRFB3Mq88+dzz//X7HmcV/VXsMf9j0dkYvShdnT v2qKyJgjSxLE4xTVYyQF/2pCBafXcHivefO+8TD8jSaXzFNuidvniWW1IcotVknY7Vev 3vaT6GB9hgNF0Cb/TF2MA9UD2w+OWgwl28vrXRCaitZtwDieJfjLpsnWFzdrdeVxHVXu d3+A== 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=FqZfoUoxy8iXzcBbOibqnO/QMawNVpGzC8pVpMz5OXw=; b=AHJ7pFxPvmtRCVd0G6a8cEssL43jgwBs/lj/+DfI9m5AyRq6LKlzMxkMj/zBzPiS/0 BxL3IG4hrz8I5JO+soEoRZ1PWojiqrBb/yqsEEihp0QphP1fEdChUNMOKQelbGFON28F x4NgR4plk4w7bnl8k9DEPtCc5bGhnPEOBt2XRbgsqfYMTpe5a7jm4ts9/xutVk1aYaRW N9cpwG44olcBezPZeU+GJtbOrLXuzROXt81JhHmP7hxejY2AXC7csl+hv0JSYO5iXm/V XmBjZ7nGlBX2tsrZ3G2CDy2g7b3dEjiu/NEiPy1vGWjtfVwMgeXKQp4zxZIqGJnlHs0D xJSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=XrakP6GB; 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=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y6-20020a17090ad70600b0023670bc014dsi3844382pju.110.2023.03.16.01.14.03; Thu, 16 Mar 2023 01:14:16 -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=@gmail.com header.s=20210112 header.b=XrakP6GB; 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=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230256AbjCPHtZ (ORCPT + 99 others); Thu, 16 Mar 2023 03:49:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44038 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbjCPHtM (ORCPT ); Thu, 16 Mar 2023 03:49:12 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14ED2ACBB5; Thu, 16 Mar 2023 00:49:08 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id a2so845522plm.4; Thu, 16 Mar 2023 00:49:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678952947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FqZfoUoxy8iXzcBbOibqnO/QMawNVpGzC8pVpMz5OXw=; b=XrakP6GBQtekN+sgg3bQqv9Ep1KiZK636rxYBHrDNRfSxKYnbN8Cthh35xM5RrFUDm xFJ2UFVsm1Q+b7nP/YVqdLhmNNwKhZb8DET900/eJBexkpozHqTrzo7htIM3wpBKjV/x mAZSMhFsdUtpsZBgVnKDUIe2MQqMSVyc1hUMVyYqJiwyov7trHFI5iA+FatMcMaUmeJJ eA3e4QcrU4yHQvsIopO3PINEORbtK+a5sXwH2TvW1dHF/Dszy69RoR/aiA7B9EMwG9E0 /3FFpmnPHFhJnsFASME3zH+Jiw+7L/ggKZoY5hZ5NrXBWKMX9YKqdxbt9fhtcmfqsRkT iAog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678952947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FqZfoUoxy8iXzcBbOibqnO/QMawNVpGzC8pVpMz5OXw=; b=nrtXH0cg+dg3UB8SJJa7BqQpkRR6WkewwZEcGol1cRpPyBUbTxblGgDCdzgZn+dRK7 OBkQ+r7c7L5hfGb0h+W1g62Rl2i3//iFgdjsLBaY98fcE/dx8xOYuncdT1lKGue5Cb/1 Zw+JoN1HpPks9vl93rQyjKJh0sjnBPk27b2/n6nwAaZNE0q1EX4NZtxfZX25+rwqOuE8 FMVpfpLVtaHT2rWO2xPvS04shpExNL1+VBBKo+PrVWI3uTO1THIMAlWnO+fBYDymljT2 I3zPLLCCcW+24Cw4dfGkpD5PFbv5UOgzgi/HQqpfdqAcpmSpOIlbtpLTRdQq8iIWHNdJ w6/A== X-Gm-Message-State: AO0yUKULLEN+rCRzNgrqUOFXtPMOdnwZ9b81C+Z+1cE1MtiCbBPF6lcu BkxqG9cH4E4rzXG6ZAGhKLz4K6gfntsKRg== X-Received: by 2002:a05:6a20:8413:b0:d5:c14c:1263 with SMTP id c19-20020a056a20841300b000d5c14c1263mr3123026pzd.53.1678952947327; Thu, 16 Mar 2023 00:49:07 -0700 (PDT) Received: from kazuki-mac.lan ([2400:4051:ea3:5910::789]) by smtp.gmail.com with ESMTPSA id 23-20020aa79217000000b005e099d7c30bsm4683618pfo.205.2023.03.16.00.49.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Mar 2023 00:49:07 -0700 (PDT) From: Kazuki H To: linux-pm@vger.kernel.org Cc: Hector Martin , Sven Peter , Kazuki H , "Rafael J. Wysocki" , Daniel Lezcano , Len Brown , Pavel Machek , Ingo Molnar , Peter Zijlstra , Juri Lelli , Vincent Guittot , Dietmar Eggemann , Steven Rostedt , Ben Segall , Mel Gorman , Daniel Bristot de Oliveira , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH 3/3] PM: s2idle: Fully block the system from entering s2idle when cpuidle isn't supported Date: Thu, 16 Mar 2023 16:47:50 +0900 Message-Id: <20230316074750.289025-3-kazukih0205@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230316074750.289025-1-kazukih0205@gmail.com> References: <20230316074750.289025-1-kazukih0205@gmail.com> MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1760511348310587849?= X-GMAIL-MSGID: =?utf-8?q?1760511348310587849?= s2idle isn't supported on platforms that don't support cpuidle as of 31a3409065d1 ("cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() too"). There is a check in the cpuidle subsystem which would prevent the system from entering s2idle. However, there is nothing in the suspend framework which prevents this, which can cause the suspend subsystem to think that the machine is entering s2idle while the cpuidle subsystem is not, which can completely break the system. Block the machine from entering s2idle when cpuidle isn't supported in the suspend subsystem as well. Link: https://lore.kernel.org/all/20230204152747.drte4uitljzngdt6@kazuki-mac Fixes: 31a3409065d1 ("cpuidle / sleep: Do sanity checks in cpuidle_enter_freeze() too") Signed-off-by: Kazuki H --- kernel/power/main.c | 12 +++++++++--- kernel/power/suspend.c | 5 +++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/kernel/power/main.c b/kernel/power/main.c index 31ec4a9b9d70..b14765447989 100644 --- a/kernel/power/main.c +++ b/kernel/power/main.c @@ -133,6 +133,8 @@ static ssize_t mem_sleep_show(struct kobject *kobj, struct kobj_attribute *attr, for (i = PM_SUSPEND_MIN; i < PM_SUSPEND_MAX; i++) { if (i >= PM_SUSPEND_MEM && cxl_mem_active()) continue; + if (i == PM_SUSPEND_TO_IDLE && cpuidle_not_available()) + continue; if (mem_sleep_states[i]) { const char *label = mem_sleep_states[i]; @@ -185,11 +187,15 @@ static ssize_t mem_sleep_store(struct kobject *kobj, struct kobj_attribute *attr } state = decode_suspend_state(buf, n); - if (state < PM_SUSPEND_MAX && state > PM_SUSPEND_ON) + if (state == PM_SUSPEND_TO_IDLE && cpuidle_not_available()) + goto einval; + if (state < PM_SUSPEND_MAX && state > PM_SUSPEND_ON) { mem_sleep_current = state; - else - error = -EINVAL; + goto out; + } + einval: + error = -EINVAL; out: pm_autosleep_unlock(); return error ? error : n; diff --git a/kernel/power/suspend.c b/kernel/power/suspend.c index 3f436282547c..55ddf525aaaf 100644 --- a/kernel/power/suspend.c +++ b/kernel/power/suspend.c @@ -556,6 +556,11 @@ static int enter_state(suspend_state_t state) trace_suspend_resume(TPS("suspend_enter"), state, true); if (state == PM_SUSPEND_TO_IDLE) { + if (cpuidle_not_available()) { + pr_warn("s2idle is unsupported when cpuidle is unavailable"); + return -EINVAL; + } + #ifdef CONFIG_PM_DEBUG if (pm_test_level != TEST_NONE && pm_test_level <= TEST_CPUS) { pr_warn("Unsupported test mode for suspend to idle, please choose none/freezer/devices/platform.\n");