Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp417822iob; Wed, 11 May 2022 18:04:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxiD1jlyZ0KBtilAx9ov7qsKMe6tBOPNGj4+OyA2pxJgYCbQju2+lG5qgkNmyN7gE/zS564 X-Received: by 2002:a17:90b:4a4f:b0:1dc:79d9:8505 with SMTP id lb15-20020a17090b4a4f00b001dc79d98505mr8150811pjb.43.1652317491548; Wed, 11 May 2022 18:04:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652317491; cv=none; d=google.com; s=arc-20160816; b=UL/pVHiUhhCV0dr8sRvVkc0KTBU80H7wHYEhUv00UurQewbZ6/ZC3MeWs9l7Ugx3gd AHfeBEhxN+7B+NdHkrCjrb7ElwsGbmEQHIR/fjIIrCfBqkOXGOZTVwPNuvRfQKxfF4N9 lh+ENg1M0c5cu8uzjLV78OPr4rKdwgOnTUqKl7KPwZMpM7oG6sgUIemLyXKgIKIlYgvg mh9VRld86he5pVwtZG668C5Zf2ktvimh+NFT1WTIXHyKMapG+td5Gn1DeFz0VOTlRMHF cg7HzX/3mws5N19+a7IT7ZtZN0cWLFM5f74dghEMzoJXhZhsVC0IK1Bmkx8qxs8+9CVk YZrw== 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; bh=A7PdCACWCn1HDIYf3HTP3XObOOrIbuLeEoI1WV5FT6M=; b=OniIfDSl63No3tVr2nor7p8ftT9BIAO9lG4ggt1fXjlUuWUa1LimGDdjr3/71pIemo xt0Txkvi7kb//ErtQ+qTIFCcHHtpaKKQDBeH9fHWbjc9KQWXjuVStk3JAlkcqZ86QNwa gjDqDo+gHoHotZ3smNPm7xGubkr9JnKbuUrP2eyA5/9Aiv78ORLhu7MBfUxY/WV+2jIX 56WpVrWQJPo9FZ+jccOSFYLNoGdPwpznXyBoMjoXdtdrpGX8TMZ4vI5iw9a/qRytpYEl i9T2yRjWM5AAgkrfugpy7rjguruBEbJWwECNlCTSVtWYpZf5dmtOnEYIabyET0TXogHG u46w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n25-20020a6563d9000000b003aad07ba5c7si1575391pgv.13.2022.05.11.18.04.38; Wed, 11 May 2022 18:04:51 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344011AbiEKPwI (ORCPT + 99 others); Wed, 11 May 2022 11:52:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343985AbiEKPwB (ORCPT ); Wed, 11 May 2022 11:52:01 -0400 Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41F866338D; Wed, 11 May 2022 08:52:00 -0700 (PDT) Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.0.0) id 8a5fbd6947a1a046; Wed, 11 May 2022 17:51:58 +0200 Received: from kreacher.localnet (unknown [213.134.181.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by v370.home.net.pl (Postfix) with ESMTPSA id 0B06066C3E6; Wed, 11 May 2022 17:51:57 +0200 (CEST) From: "Rafael J. Wysocki" To: Linux PM Cc: LKML , Viresh Kumar Subject: [PATCH v1 1/3] cpufreq: Reorganize checks in cpufreq_offline() Date: Wed, 11 May 2022 17:48:41 +0200 Message-ID: <4756874.31r3eYUQgx@kreacher> In-Reply-To: <5585781.DvuYhMxLoT@kreacher> References: <5585781.DvuYhMxLoT@kreacher> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 213.134.181.161 X-CLIENT-HOSTNAME: 213.134.181.161 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvfedrgeehgdeltdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfjqffogffrnfdpggftiffpkfenuceurghilhhouhhtmecuudehtdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurhephffvvefufffkjghfggfgtgesthfuredttddtjeenucfhrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqeenucggtffrrghtthgvrhhnpedvffeuiedtgfdvtddugeeujedtffetteegfeekffdvfedttddtuefhgeefvdejhfenucfkphepvddufedrudefgedrudekuddrudeiudenucevlhhushhtvghrufhiiigvpedunecurfgrrhgrmhepihhnvghtpedvudefrddufeegrddukedurdduiedupdhhvghlohepkhhrvggrtghhvghrrdhlohgtrghlnhgvthdpmhgrihhlfhhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqpdhnsggprhgtphhtthhopeefpdhrtghpthhtoheplhhinhhugidqphhmsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtoheplhhinhhugidqkhgvrhhnvghlsehvghgvrhdrkhgvrhhnvghlrdhorhhgpdhrtghpthhtohepvhhirhgvshhhrdhkuhhmrghrsehlihhnrghrohdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=3 Fuz1=3 Fuz2=3 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE 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 From: Rafael J. Wysocki Notice that cpufreq_offline() only needs to check policy_is_inactive() once and rearrange the code in there to make that happen. No expected functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/cpufreq/cpufreq.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) Index: linux-pm/drivers/cpufreq/cpufreq.c =================================================================== --- linux-pm.orig/drivers/cpufreq/cpufreq.c +++ linux-pm/drivers/cpufreq/cpufreq.c @@ -1590,24 +1590,18 @@ static int cpufreq_offline(unsigned int } down_write(&policy->rwsem); + if (has_target()) cpufreq_stop_governor(policy); cpumask_clear_cpu(cpu, policy->cpus); - if (policy_is_inactive(policy)) { - if (has_target()) - strncpy(policy->last_governor, policy->governor->name, - CPUFREQ_NAME_LEN); - else - policy->last_policy = policy->policy; - } else if (cpu == policy->cpu) { - /* Nominate new CPU */ - policy->cpu = cpumask_any(policy->cpus); - } - - /* Start governor again for active policy */ if (!policy_is_inactive(policy)) { + /* Nominate a new CPU if necessary. */ + if (cpu == policy->cpu) + policy->cpu = cpumask_any(policy->cpus); + + /* Start the governor again for the active policy. */ if (has_target()) { ret = cpufreq_start_governor(policy); if (ret) @@ -1617,6 +1611,12 @@ static int cpufreq_offline(unsigned int goto unlock; } + if (has_target()) + strncpy(policy->last_governor, policy->governor->name, + CPUFREQ_NAME_LEN); + else + policy->last_policy = policy->policy; + if (cpufreq_thermal_control_enabled(cpufreq_driver)) { cpufreq_cooling_unregister(policy->cdev); policy->cdev = NULL;