From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796326856; b=30TRSwOjCjpDjtgnXrXnVzPjlqHePQ6qSjAZ15R4JFsUaAnIb+Ch8LI1gXi4EYLDgi/+ 6Jy+qOvboTGc4jkLF+fYlikTZx2PuLy22RlC3ODWg5iMeQUI4v5GAjsLXCUnbxSf8ipyw Ce9o71ipOCy6aEv+MP93V4B9bovFl/OulEtoa4oYOKoPpofpvf7n5jmZ7qP7vIt4Qkqlb MTKcgSLOO8cWEdlBX7TsA0Famo7RU6Z48dFLB5CFuvkSjGhTnjKiA2X2I2F1QI1Ryz5xk JbFevrEeQxQgWpjF59HCQ44vqaZyzRj47xVKZYiuESGUwduJsV4B5ZIFGYG7nZ4TW6Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326856; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=fItU4SRjoLfNK95KOGrUglftU5EFr9Eo05ATw/HWBMg=; b=jxgf8jnTGg8UKcOp14UYF+lpo/Up1caON+WovvSzjslMCtGrWWNoOZuecduFrxyYRkrM oz1cueKNNYtE7/KmuJTM+0WLCmwstUqVzzjgYHSP7icpmTgcNd64z9DW8eMGFxMJTdSKL 8SqVyL7DaKWQzVbaRhdLh7T/+eMHNhFt5gG3HndEqPIoZQxKBvg4cnHysmg4Ad71xrd6B U+2/f3rKXuclb04/AlNYHMOHL7gwDCqIM4ahtX1bHRCaaQySdX9Uw6XKKZkB1+VlydFw2 7fthICOUDl9ULWbasv2ADulRvRjpYjQaiBHAmOzJKe5lB3KhrRCy1upHntzRf8e3s5Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XSPDbWOm; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5322060A3808 for ; Thu, 3 Dec 2026 19:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XSPDbWOm Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BBAE1F000CE; Thu, 3 Dec 2026 19:40:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326856; bh=fItU4SRjoLfNK95KOGrUglftU5EFr9Eo05ATw/HWBMg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=XSPDbWOmvQFQ0HMvivSN7Ub7yM+cndjpfAqaO3S7SI01eBy9Jcvp8IaalCbdhqGF3 wJGrjCEpVKvTTSKOOklYyrepFlJpWjmjXzVe10o7qHXNDeXUm9TW2nkymXH6yLHVgy I/hD0FNJni2Er0zWI8Oy8dI7zFkRasOvYLMFoGxBfnBs8nausVV65JdYt0uECu5JwR 0+QcqGML/dTEd5aSfR0qWVVQ3BleQZtLqN+Y5QXQVjTmhH2ioF/h2ThT8kEPkQvbUS MS/sSYgh1krkeVyZxPeC7aIEgN3CNA2RQvya1nGGWIVizmGn19OpVBaCs2l98A3VZ1 2TjXRKrjXMWDQ== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Viresh Kumar , Mario Limonciello , Sudeep Holla , Sasha Levin Subject: [PATCH 6.1.y 1/4] cpufreq: Consolidate some code in cpufreq_online() Date: Thu, 3 Dec 2026 14:40:50 -0500 Message-ID: <20261203194041.666445-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120248-concerned-system-eb91@gregkh> References: <2026120248-concerned-system-eb91@gregkh> X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Rafael J. Wysocki" [ Upstream commit 387b51709db546033cf9a940860b6614a5cda5b6 ] Notice that the policy->cpu update in cpufreq_policy_alloc() can be moved to cpufreq_online() and then it can be carried out under the policy rwsem, along with the clearing of policy->governor (unnecessary in the "new policy" code branch, but also not harmful). If this is done, the bottom parts of the "if (policy)" branches become identical and they can be collapsed and moved below the conditional. Modify the code accordingly which makes it somewhat easier to follow. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Viresh Kumar Reviewed-by: Mario Limonciello Acked-by: Sudeep Holla Tested-by: Sudeep Holla Link: https://patch.msgid.link/13741234.uLZWGnKmhe@rjwysocki.net Stable-dep-of: c5bdb8757372 ("cpufreq: Skip inactive policies in cpufreq_driver_target()") Signed-off-by: Sasha Levin --- drivers/cpufreq/cpufreq.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 931ab927316bd..de9dec99781b0 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1274,7 +1274,6 @@ static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu) init_waitqueue_head(&policy->transition_wait); INIT_WORK(&policy->update, handle_update); - policy->cpu = cpu; return policy; err_min_qos_notifier: @@ -1362,17 +1361,18 @@ static int cpufreq_online(unsigned int cpu) /* This is the only online CPU for the policy. Start over. */ new_policy = false; - down_write(&policy->rwsem); - policy->cpu = cpu; - policy->governor = NULL; } else { new_policy = true; policy = cpufreq_policy_alloc(cpu); if (!policy) return -ENOMEM; - down_write(&policy->rwsem); } + down_write(&policy->rwsem); + + policy->cpu = cpu; + policy->governor = NULL; + if (!new_policy && cpufreq_driver->online) { /* Recover policy->cpus using related_cpus */ cpumask_copy(policy->cpus, policy->related_cpus); -- 2.53.0