From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E0752C21F7 for ; Tue, 10 Mar 2026 13:18:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773148685; cv=none; b=fx1/DG7Gpu+h3172Pwx6ND39JK53QFWDCcJAZQd3vKT0DTPusXTXjgY2sPo9yD9zt8flbhq1ISsGb0QuG4Wg0sxNXRa20Dr+3iQaTxhiNBntK7r7/dDsgbNKupzaBYp0lCLzLq+Svovc5WEU0/B7z5iJ5CBC1GJeMqDjRvMrhdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773148685; c=relaxed/simple; bh=X0hmFSpchItCFK/n/iWAzjP04Cuv3qg7aIt6bH/Idt0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=MYipV83WR3ugXxJbZUJo2lIVfTzJ2oz5nE1yl2JtZH0G+dRYjAoiA0Qaj6olRcS/+6riaSqelS6Qe/WYEyU3OAlHYcxSZFctlwehj9DmxSzA5zCwFqm/bmnkPRTWsgXr/6p0S8fPBdWdUmNXh+sxTxuNe9fWYrmtLKUBCnY6SHA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=laU5/Dlg; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=RdL3k7PC; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="laU5/Dlg"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="RdL3k7PC" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62ACafKA1503509 for ; Tue, 10 Mar 2026 13:18:03 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= QeRVERBetYXJ7uyxSrvFn8RqQTgPuZs/VzIemLuHUTc=; b=laU5/DlgxSxiBEhX uunTU3NLmI6IG2DsiVTp49DgW1mnd2RN0pZH299yv9GlMP4qx4EpI0c73IgD35kL RQ21cWdXEAaHcPYqh3j5y899leyDJyhRHIPwgq9Nj+osAdf9ZagpYyGABEzQ/h/7 V+dT5AarTQW0jl1IfY+PgHm1JOUWyOHdCowvMO9++HAQuiumB4BP2RpN1TA/umu+ F2tDZxi8aQkh7gdRwKNZ2QZ2AcpXEzhqIi1DHNpv7eDghsvDJhZPdPCJJ1D4i9Go qc1DphsmHgl7M1gPOLC3mjpfxxDnvRxRlTHqRWuAhG2fUthbRT+vpIK+ORjXcgi0 IklEsQ== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ctdf8hmr6-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 10 Mar 2026 13:18:03 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2ae6dd98043so64444875ad.3 for ; Tue, 10 Mar 2026 06:18:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773148682; x=1773753482; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=QeRVERBetYXJ7uyxSrvFn8RqQTgPuZs/VzIemLuHUTc=; b=RdL3k7PCwq0EeXqnmtsY18nQByWGzvenE9zizcPBMKJHBZ13cprnbc9tbG4PH3R3H5 H18zxnqsGJ1xndgOpuBKHhvZ15hxRhYUgZ2vDiHPYgYFcn40EzAwJWO40DO8PNv4B7UC bJ0CYXAEbLjc0fAjExXsD+10ra4Mm2/sWf87vOUVTAP3FgMcNcRUS6S30jvZymFb96Q0 12tHt3ZuPxfemLrjsFqBn+UtMMz1ZtVvK1zQFJPHGDrNxOR2ieiO2X36yV7KknLRzQ4N iz2M0a1wGIuppjOyf2JFfErfmnsPQ7JWo8vLl732Vu8iVjDgIpioB3+bBieDHqNWePAh y5Tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773148682; x=1773753482; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=QeRVERBetYXJ7uyxSrvFn8RqQTgPuZs/VzIemLuHUTc=; b=ngFKQ4YZfdiEBhGKkUJambgMgsEhk8/qkrhRm+A1S4o3FNMJ8YlZSVL3AGuLmZ3cfa SSonxrBUequmrEOS0cuq1AsUEpelA8KDe/SEtGb1k+BK5Oh6JyJy4xjraZZdYq5X0rHF qBWOyjGjDQspt4XwIZ5E20HiQwC/oMi264Nxdl1kztyfMmtevfGvYBIBfppPuOBqXZJL b4vDRPRRMgI+MPnt8tPdn7YScAwM8J3prdVqa8xJ6byZICboP82eZE2ZcY+WK8TrbzXT lrdx68BmCTR475sFwmB+3bk8PgDMJCjTbu/8Wyo1eVpO0HxgTJEYx1HtpMPCbvNHcFWn hfXg== X-Forwarded-Encrypted: i=1; AJvYcCXXr9xC2gwdGaLQNXfCUEFrkCDOOSYwrvzZeem7vsTEZlHmGn4Nwx6dj/kdttj3IltJ7LO4gUEJKZvtSeE=@vger.kernel.org X-Gm-Message-State: AOJu0YzbiNiEdVt+xllNDvmAT1qfj6ivuaL5t/9CgHl6hLjRFOwoGzvQ qBAX0Cn8pvvOCh9R+4ylWUKQ0VILzLFgPEwJ78UakHXwFbEqLmTTvbd2Yp923xmjSKIOPI9tltb he5/1+7Qd36DfVpngRO4+LFP1nTgr+p/OeQn/vT2FbUDJ1srpIcBpT8aZuYKRm/Aup40= X-Gm-Gg: ATEYQzwRYq9OSjwA3kfQnRGPnKNh5b+7IPUz23qGORii7R3xSHzzHqqbqzUxShKCogg uQSfd6bAG02+fact4b+6D0tLSPnAj4S4Ug/4YsV2fmq/zWvzG8IcEHqgIZ9C4R54C0YcMrswddI 4uS2rFedqYyhFVT0E4uiSU9FTCv7u3O4x7+2+ZN2zlQMrvAntosKFapfYGYrDzkZ09+xe5c/3Wp DLqHOnl1SIL5LqyrM/PEj1eRfDo/51/5pyNfdaa3tv4fbXSF+4WM4eRm8k+DitbtGkQ1v2Dwl2+ hqfDJ40iH8TXI9u5JTCnE24m0afCVomwjCMEnMWawlQ61+/F4fDIdvcTZmK7e2uE3LefQsQH5Ii XMaVqcxEDiF9EjRKtUqgu5CMlYNzbJ3A9QtmiegC39ZmHSsQPpPhZ6vIWsh4UPBw0J1Y2Q3gC8O M6OwYd7fwIflLrwnKOcA== X-Received: by 2002:a17:902:d2d0:b0:2ae:492c:f8e6 with SMTP id d9443c01a7336-2ae82367d1fmr145871465ad.1.1773148681857; Tue, 10 Mar 2026 06:18:01 -0700 (PDT) X-Received: by 2002:a17:902:d2d0:b0:2ae:492c:f8e6 with SMTP id d9443c01a7336-2ae82367d1fmr145871135ad.1.1773148681321; Tue, 10 Mar 2026 06:18:01 -0700 (PDT) Received: from [10.133.33.216] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae83fb4401sm150287805ad.74.2026.03.10.06.17.58 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 10 Mar 2026 06:18:00 -0700 (PDT) Message-ID: <05feb9ed-3257-452e-98e9-89637431a347@oss.qualcomm.com> Date: Tue, 10 Mar 2026 21:17:56 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cpufreq: conservative: Drop cached requested_freq To: Viresh Kumar , "Rafael J. Wysocki" Cc: linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: Content-Language: en-US From: Zhongqiu Han In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzEwMDExNiBTYWx0ZWRfX9bmxbvdV5Tlu 2bIdyYyqblNq/LnrgFPQS8C7tRztzzfEZgEiOAZJtmm6mkn4mOxOhCBVWYV4qSINbw/ZOSS8V8D zLpXoGS7HN4/dsP8wZ7XuIHybi/UnCn24Kg6nrueKfkkXZhOhTkwg+90EmukUljz67M3Bc9PCX/ TY57rH92I7lsYwEsDWC8jTUZZdorjZPkpzcp4+gIflWfnXVsxi5pAXREXhGUfkeJUft4SNoL1ix zs5dHJNLWqJtEdkeW14loNiQJ6POa9It5PiYwsWIzfmuc56/y93NZRRf+tpBh4T6AWmhwut3OCw vvrWG8qdF/oIfOFRQuyjAFKP+CuctaIBp1DvsR2wK20BmZ1D4tX9JD51/ifce59NlA4DLase5LP xgey7sNCIrIcu/JBMSwgRDu4AwoEX6avHEulG5Jqmv1R22w7Joh4RecJAtUx4G8l/0r+RxyBpHr fyGNEJrnyoQCw2r4c9g== X-Proofpoint-ORIG-GUID: MfUDN5MXuWgB_OtMUtekD3ZFCSvrG__a X-Proofpoint-GUID: MfUDN5MXuWgB_OtMUtekD3ZFCSvrG__a X-Authority-Analysis: v=2.4 cv=b+W/I9Gx c=1 sm=1 tr=0 ts=69b01a0b cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=VwQbUJbxAAAA:8 a=i0EeH86SAAAA:8 a=KKAkSRfTAAAA:8 a=4yIxzue803bsba6ReOAA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-10_02,2026-03-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 adultscore=0 suspectscore=0 phishscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 malwarescore=0 lowpriorityscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603100116 On 3/10/2026 2:34 PM, Viresh Kumar wrote: > A recently reported issue highlighted that the cached requested_freq > is not guaranteed to stay in sync with policy->cur. If the platform > changes the actual CPU frequency after the governor sets one (e.g. > due to platform-specific frequency scaling) and a re-sync occurs > later, policy->cur may diverge from requested_freq. > > This can lead to incorrect behavior in the conservative governor. > For example, the governor may assume the CPU is already running at > the maximum frequency and skip further increases even though there > is still headroom. > > Avoid this by dropping the cached requested_freq and using > policy->cur directly. Hi Viresh, Thanks for the patch. The fix looks correct to me for the reported issue. I do have one question though - should we also consider the interaction with commit abb6627910a1 ("cpufreq: conservative: Fix next frequency selection")? The cached requested_freq can diverge from policy->cur when the platform may change the actual CPU frequency outside of cpufreq interfaces, causing cs_dbs_update() to incorrectly assume the CPU is already at policy->max and skip frequency increases. Using policy->cur directly avoids this. This direction was already argued for in commit d352cf47d93e ("cpufreq: conservative: Do not use transition notifications"), which noted that "policy->cur can be used instead of [requested_freq] and then the governor will not have to worry about updating the tracked value when the current frequency changes independently." However, that change was subsequently reverted by commit abb6627910a1 ("cpufreq: conservative: Fix next frequency selection"), which noted that using policy->cur directly broke the algorithm when freq_step is small relative to the distances between available frequencies. In that case, the governor may not be able to stay within a narrow range between two consecutive available frequencies and instead jumps through steps faster than intended. May I know am I missing something here, or does this patch potentially reintroduce the same issue? Thank you > > Reported-by: Lifeng Zheng > Link: https://lore.kernel.org/all/20260210115458.3493646-1-zhenglifeng1@huawei.com/ > Signed-off-by: Viresh Kumar > --- > Lifeng Zheng, can you please give this a try and provide your Tested-by as well > ? > > drivers/cpufreq/cpufreq_conservative.c | 16 +--------------- > 1 file changed, 1 insertion(+), 15 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c > index e0e847764511..c69577e4f941 100644 > --- a/drivers/cpufreq/cpufreq_conservative.c > +++ b/drivers/cpufreq/cpufreq_conservative.c > @@ -14,7 +14,6 @@ > struct cs_policy_dbs_info { > struct policy_dbs_info policy_dbs; > unsigned int down_skip; > - unsigned int requested_freq; > }; > > static inline struct cs_policy_dbs_info *to_dbs_info(struct policy_dbs_info *policy_dbs) > @@ -59,10 +58,10 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > { > struct policy_dbs_info *policy_dbs = policy->governor_data; > struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy_dbs); > - unsigned int requested_freq = dbs_info->requested_freq; > struct dbs_data *dbs_data = policy_dbs->dbs_data; > struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; > unsigned int load = dbs_update(policy); > + unsigned int requested_freq = policy->cur; > unsigned int freq_step; > > /* > @@ -72,16 +71,6 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > if (cs_tuners->freq_step == 0) > goto out; > > - /* > - * If requested_freq is out of range, it is likely that the limits > - * changed in the meantime, so fall back to current frequency in that > - * case. > - */ > - if (requested_freq > policy->max || requested_freq < policy->min) { > - requested_freq = policy->cur; > - dbs_info->requested_freq = requested_freq; > - } > - > freq_step = get_freq_step(cs_tuners, policy); > > /* > @@ -113,7 +102,6 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > > __cpufreq_driver_target(policy, requested_freq, > CPUFREQ_RELATION_HE); > - dbs_info->requested_freq = requested_freq; > goto out; > } > > @@ -137,7 +125,6 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > > __cpufreq_driver_target(policy, requested_freq, > CPUFREQ_RELATION_LE); > - dbs_info->requested_freq = requested_freq; > } > > out: > @@ -310,7 +297,6 @@ static void cs_start(struct cpufreq_policy *policy) > struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); > > dbs_info->down_skip = 0; > - dbs_info->requested_freq = policy->cur; > } > > static struct dbs_governor cs_governor = { -- Thx and BRs, Zhongqiu Han