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=1796326229; b=x7RsXv+GNPNJ5j9FvfmOjmKu1drobzt7a3BIVGGYqwjL+BV+5tSNv46mYSYvjg0fmQWO n7bMaIwd0vqYpp5VqvAUqAPRDfcJvDsWTyAKdMmeRPHoYHZbHWnq+ROiNgn8CQl1FjnXv te+bE90nuf1nlaZIPSPUGRJZxdy/jlRpOiKt72onP+c1hpM8UqLac+/7dRZ+hvuwf2s82 Yffvwtfp+ZDePxWXkDfVWP60lPsMLoH0AJ2XgLfLiaJuVz89hzu1ivPE/Z5ky5zuIKcou 4ztBEVq6NGyo0A1cAz8i19iuw9qYH5PnLWXf3WxbjcI2pqwmEKnqEmLQRozQGmAELCA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796326229; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=5Mz75gyxs3a5rq1rwOlB7GUqMlX2RemfTwhFH1wNvO8=; b=FZnvgYMOdrUG0zLtg/4g8/uwe9LlTCuwIagYA2bdjFP3lIkIAgMHFqYoM9g5L7A0GQn2 AQhLVGL+fVeXq79Ets3qtWmtzK97fO1vTsKaihchJhDuRGt3jQWgy5gSKRlL8CJgtQuop KQOxdAm2a8vkwbKmQGJt+PSCAanulG1zWJpiY+bR6SaDn2P1qE9h12QHuCr2ji/E9Q9ZG tgngiM2ju2gTzjyAfsr+8GrLzwlFw5mrYB9kIQBV4tOJH9UCxCKFcmfoGMtJaQkXD8+SJ bOfMoMgCQJ/pq61ZtiAsYgsqUTmrv2SbrCDiHWnZEyGX3vGnh4tXkiSwb8OjQNGY/bA== 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=jDcbR1rz; 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 71976606A687 for ; Thu, 3 Dec 2026 19:30:29 +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=jDcbR1rz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E6F71F000C2; Thu, 3 Dec 2026 19:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796326229; bh=5Mz75gyxs3a5rq1rwOlB7GUqMlX2RemfTwhFH1wNvO8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jDcbR1rznygvyIe56Dj2idVT7kbez7PalVd7fQG+6wOQJ9DdqMhF3V50kE7Xwg0qB Nwi8zVVRQVNXcTLZKU/x8VNhIPtE5iEUIegWrJQ1z6W5kBHrmtB3ZqgaVVdZeJ5sGi 1lUkghfr3qMlE+dpFWMOCM+TzIYw9yImvk3Copo0APgWv7H9adW6LXlcj8gfsvkgG7 72b68tQEPOwM3lVn2fIiMMtXT/3oi2gkMtPnIP+LqqIvkWtR+oxEG4oUpaiu0zZkzp +77UakHzdCXYH/JdUYPFOj5pc+OkguoZjSwixoxB/S+3ELFl2HrAft1ZduBmaQd0SX bEt3uBScPnGMA== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Viresh Kumar , Mario Limonciello , Sudeep Holla , Sasha Levin Subject: [PATCH 6.6.y 1/4] cpufreq: Consolidate some code in cpufreq_online() Date: Thu, 3 Dec 2026 14:30:23 -0500 Message-ID: <20261203193010.628401-1-sashal@kernel.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <2026120247-residency-drab-33a4@gregkh> References: <2026120247-residency-drab-33a4@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 7c9e7d6556d38..6450bca6e3b74 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1323,7 +1323,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: @@ -1411,17 +1410,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