From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=113.46.200.225 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796026335; b=X2r9mzE9GHCtAnJLFye5AGpCLiN8ySfdu0vkyCMOi3tVvhk4uMLnLscYORUVRP8buvXe s8hOg/I4o0Mog0ZWTUeO8EVFBvMEiGjrHAtH6bfGBNfrZSYHfzAk3ks7/+qqlj62oy2lq zwxHWFzbmsB7kAMG/UF9PYOIF+v60FhmmhjOaArMNLkLFpy3sfsqpgKoIU0WEOywYDVdD Q20nw+qY9V6nLZni0BlEXsCSAGwii4it7Akzp2OPHWPy6mlxQwbv1bcdUtjOlQBJK4KHa ynl6BoaFiGqWPl7YVaMtPStN+ZrVbr7uHlwtFnqiWxHv8X8hd611nEdpxxOGe+RfH3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796026335; h=DMARC-Filter:dkim-signature:Received:Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:CC:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding:X-Originating-IP: X-ClientProxiedBy; bh=YCAOOT6jueu3coF3rAZC/azRz8me6PnsN16JRst1ad4=; b=xuKQKnR5l1d4YYEMhmuABtSCynxLAEsLCXxTJLgUBudpeRYc77viVlC2fej8kYvlpaLN ZHrhCuKNWZtxZsS5JmktFYW0joqOHbvleW7u+WkAxQQta2s2d842KbEyb46qHb1LmP2WL +KhxhaXWs/yESJmfa+iyBycIi0MTzBUKFajIku7SVyW10JS8cZSdKGn3kLSZDuPVH7nw9 w7T6V20ZdZPZ9RoJPC5GP3WCB+SS8gdZErZP6eqhN95Cc5sBRfORbzb4BRf2A6weZN2D7 OI4R+UI1idaIRHG7zBD6UdI6vh4IFzJvkz+S+lm12x4gKufbacQhgMx/yrHjy+SCMBw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; dkim=pass header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=rFNanj8n; arc=none smtp.remote-ip=113.46.200.225 Received: from canpmsgout10.his.huawei.com (canpmsgout10.his.huawei.com [113.46.200.225]) (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 7713D606A325; Mon, 30 Nov 2026 08:12:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7713D606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=huawei.com header.i=@huawei.com header.a=rsa-sha256 header.s=dkim header.b=rFNanj8n dkim-signature: v=1; a=rsa-sha256; d=huawei.com; s=dkim; c=relaxed/relaxed; q=dns/txt; h=From; bh=YCAOOT6jueu3coF3rAZC/azRz8me6PnsN16JRst1ad4=; b=rFNanj8nTiSb6IXfeCNcEyU8kn+YQZ1uPwNqdTzgoeP91wxd90ZjpTClgPEcZUXzsBQYFne3U KHitr4uSvu0lqFquuLEQUxD2ExyVhay1pRB4unu2ZF2SyOHWqQ63J/Y5kKmwumabCLyeNoINGWo 3kFHVKMpE7UodYVmJCCQlxw= Received: from mail.maildlp.com (unknown [172.19.163.163]) by canpmsgout10.his.huawei.com (SkyGuard) with ESMTPS id 4jdGvR1wFkz1K99h; Mon, 30 Nov 2026 16:11:47 +0800 (CST) Received: from kwepemr200004.china.huawei.com (unknown [7.202.195.241]) by mail.maildlp.com (Postfix) with ESMTPS id 4C1804057A; Mon, 30 Nov 2026 16:12:08 +0800 (CST) Received: from [10.67.121.62] (10.67.121.62) by kwepemr200004.china.huawei.com (7.202.195.241) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.45; Mon, 30 Nov 2026 16:12:07 +0800 Message-ID: <744b868b-55af-4a12-86a8-f4fd5d132e6a@huawei.com> Date: Mon, 30 Nov 2026 16:12:06 +0800 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v4] cpufreq: Keep global boost enabled after partial enable To: Jiangtian Feng , "Rafael J . Wysocki" , Viresh Kumar CC: Zhongqiu Han , Christian Loehle , Ananthu C V , Pierre Gondois , , References: <20261127060407.732709-1-jiangtianfeng@linux.alibaba.com> <20261127090513.910723-1-jiangtianfeng@linux.alibaba.com> From: Pengjie Zhang In-Reply-To: <20261127090513.910723-1-jiangtianfeng@linux.alibaba.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: kwepems200001.china.huawei.com (7.221.188.67) To kwepemr200004.china.huawei.com (7.202.195.241) Hi Jiangtian, On 11/27/2026 5:05 PM, Jiangtian Feng wrote: > When global boost is enabled from the disabled state, a failure after > one or more policies have been updated successfully currently restores > the global flag to 0 without rolling back those policies. This leaves > them locally enabled, with their boost-related driver/QoS updates > retained, while the global flag rejects per-policy sysfs writes. > > Keep the global flag enabled if at least one policy_set_boost() call > succeeded, while preserving the existing error return path. Global > boost = 1 grants permission to boost; it does not require every policy > to have boost enabled. The mixed per-policy state is therefore valid > and individual policies remain accessible through per-policy sysfs. > > Restore the previous global state on disable and when no policy was > enabled successfully. After a partial enable, keep global boost enabled > so users can repair individual policies through sysfs. Do not roll back > earlier policy updates. > > Qoder, an AI coding assistant, helped analyze the issue, develop the fix > and state matrix, and draft this description. > > Fixes: 218a06a79d9a ("cpufreq: Support per-policy performance boost") > Reviewed-by: Zhongqiu Han > Signed-off-by: Jiangtian Feng > --- > A failed write of 1 can leave the global flag readable as 1 when at > least one policy was enabled successfully. The write still returns an > error, and the resulting mixed per-policy state remains valid and locally > repairable. > > Changes in v4: > - Drop the RFC prefix after review and add Zhongqiu's Reviewed-by. > - Remove the human-review/DCO-process note from the posting. > - No code changes from v3. > - Link: https://lore.kernel.org/linux-pm/20261127060407.732709-1-jiangtianfeng@linux.alibaba.com/ > > Changes in v3: > - Correct the changelog and comment to describe restoration on disable > or when no policy was enabled successfully, and local repair after a > partial enable. > - No code-logic change from v2. > - Link: https://lore.kernel.org/linux-pm/20261127014937.413500-1-jiangtianfeng@linux.alibaba.com/ > > Changes in v2: > - Remove goto/out_err from the function using cleanup guards. > - Simplify the restoration condition to !state || !policy_success. > - Link: https://lore.kernel.org/linux-pm/20261126110903.3747240-1-jiangtianfeng@linux.alibaba.com/ > > No normal in-tree trigger for the partial-enable sequence has been > identified. Same-state global writes already provide a resynchronization > mechanism. The same-state disable/resync failure noted by Zhongqiu is > left for separate discussion instead of expanding this patch. > > Validation (unchanged code from v3): > - mainline ARM64 defconfig build of the complete Image > - checkpatch.pl > - eight-case old-global/request/success state matrix > - independent static control-flow and locking review > > NOT_RUN: > - runtime fault injection or reproduction with multiple policies > - global/local concurrency, hotplug, lockdep or KCSAN testing > - CPPC, SW frequency-table, ACPI or AMD hardware frequency/QoS testing > > drivers/cpufreq/cpufreq.c | 12 +++++++++--- > 1 file changed, 9 insertions(+), 3 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 4332cb114070..57f1874e087a 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2887,6 +2887,7 @@ static int cpufreq_boost_trigger_state(int state) > struct cpufreq_policy *policy; > unsigned long flags; > bool boost_enabled; > + bool policy_success = false; > int ret = -EOPNOTSUPP; > I agree with treating global boost as permission. When global boost is 0, boost must be disabled for every active policy. When it is 1, each boost-capable policy can have boost enabled or disabled individually. Policies without boost support remain disabled. Under that model, global boost can be 1 even when no active policy supports boost. Since 77cf053b041f, writing either 0 or 1 to the global knob returns -EINVAL in that case. This can happen on CPPC systems with no boost-capable policy, or when all boost-capable policies are offline. Initializing ret to 0 in cpufreq_boost_trigger_state() would let the core record the requested global setting and return success for either write in this case. Errors from policy_set_boost() would go through the failure handling in your patch. Thanks, Pengjie > guard(mutex)(&cpufreq_boost_mutex); > @@ -2911,6 +2912,8 @@ static int cpufreq_boost_trigger_state(int state) > ret = policy_set_boost(policy, state); > if (unlikely(ret)) > break; > + > + policy_success = true; > } > > cpus_read_unlock(); > @@ -2918,9 +2921,12 @@ static int cpufreq_boost_trigger_state(int state) > if (likely(!ret)) > return 0; > > - write_lock_irqsave(&cpufreq_driver_lock, flags); > - cpufreq_driver->boost_enabled = boost_enabled; > - write_unlock_irqrestore(&cpufreq_driver_lock, flags); > + /* On failure, restore old state unless partial enable needs local repair. */ > + if (!state || !policy_success) { > + write_lock_irqsave(&cpufreq_driver_lock, flags); > + cpufreq_driver->boost_enabled = boost_enabled; > + write_unlock_irqrestore(&cpufreq_driver_lock, flags); > + } > > pr_err("%s: Cannot %s BOOST\n", > __func__, str_enable_disable(state));