From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 425693CCA09 for ; Thu, 23 Apr 2026 05:39:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776922794; cv=none; b=AD7NtS1dIu56XFzgWgQugLuRLIPfV7LgSUfNeA3wXQzk5MSPnok8s/sm4IgfNp/LRDxeg5lO75i+N1MkQYBFroqm4nEQ7n4ZTjiwXavtmWluTxQ4FZGrJqMnSFvDXp5g9iJSAxyjXrdZwHB6Oin1vDpWWp4xjUbSpaNH/dR0eGg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776922794; c=relaxed/simple; bh=NRlQOT/MrDZNinKs5KppazJLAiX8V7buz8mCDi2WVP8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=A6MdbQsjL5UYbhXSgJsOehDG5A7+JoZVCinDLYMeItrIU7DmHFhraxayTJNL9PUIVsLso4LE86lbt8O3gVJiM1QzT2rN+FHT6upZO3PbsBZE0HIbBrvFgmTOcm4lQ4f2GOWtOX4/FZPxyx7qEGnVfoWb6r3fa/4ioM5td4khAQs= 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=OpXjDeXh; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=fyq0Vn0c; arc=none smtp.client-ip=205.220.168.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="OpXjDeXh"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="fyq0Vn0c" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 63N2sSkC1230326 for ; Thu, 23 Apr 2026 05:39:51 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= oWyLJPmJ5MEOaqp8lTB78ArF7rnI1vWecPhy5LBowBI=; b=OpXjDeXhED1juNgZ j4iARDeDRfYDiqJ70f8PdPvShDM+3cG7BAQEwc7FWmhAFMoBuSQamUAgoKIsVhNc t2gw+FGcyajj/kKeVTvdQwh5eoANJOM8QJiwCmtcdANmNHCeLZKZGGD+hnuffVZ/ U9WaNTR10zjFm8DQl0E1DJtj0/Y3LpbMYRoo9KSi44I+XF85TFvv7GVs4p7X9G0S tLpjTnQGeoVaJXOfCY23gBOujDBgB+FLjYh5Fh6rTrIRE5KAbvUALqJMPUcqDbzR efraCCRXDdGdIF6hhJzP/g8zsDBcRS4h2KFIQc5OTyjSqpP8ztFhbUtMahL5nq/m Dmd3bg== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4dq1h6abf8-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 23 Apr 2026 05:39:50 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-82fa1c94b37so4157007b3a.0 for ; Wed, 22 Apr 2026 22:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1776922790; x=1777527590; 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=oWyLJPmJ5MEOaqp8lTB78ArF7rnI1vWecPhy5LBowBI=; b=fyq0Vn0cX5sYQwkjojeZwtaMi/YMCacqzzNPg81iL+Tk98yPR14E/vrvm9fRTzLb0T Hfw1SmZJdfC3bcGGzFLPfVmlR+39zty2Xtjg2E9LbmgBED2u+HZDICzPioKFT3E7/IwO ICXefrjYS9FoljTQQYEH2UQOof5ElrgWbAbFF8bBgnBpvEI47BaKJdnuP5Llw8JI+dLz iaIDGE4+JdYbW2XhXF8oYLgOYHAaQKyzEu6oce6ylXcJXu2KIlg/Vl/vjkTFdsy6JDhf 0vBlg+bBqiF7MHU3MODG2nmYsDoRZnA23lkUCeq0aLi0Th416oXCLBXpQ1Z7ubAzCEsP 3O3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776922790; x=1777527590; 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=oWyLJPmJ5MEOaqp8lTB78ArF7rnI1vWecPhy5LBowBI=; b=nFy/mJTXbMM//BIb5176RmV6Z2lMd8JUh9jjn8IN7PtBbK+qO/jF1X+fT5i60Dw83T JXkeZcVvbl+ry/PDstdYKrF5hvVfQI0rJW598bVx1ScUgsgTQBLQS1E7FzNsRQOIedg7 EcqV4flSwfptkhbCUZ/PcoKzeoYbSZgd/t0NAyDVGk7sv1wBNwNeLBqo00ZeosIqBC/i GB87QYUet8jlVNGnfT4Y0UBYt4K2f3m6OYoFBwVP/Dsg28oDRRFuWtLLmk2y9f4OYehK kKl6Yn2j7xfEq05k1IQq6V586zYZOa35VeVUpkLk8sbkZNU5fsD9wIneLKpQ2JZoTy9f o2SQ== X-Forwarded-Encrypted: i=1; AFNElJ83pcwdSXbWMjxqlVdlebBbH172VRAXiKACzbsXcx116aLflIr6YuuaivBzPdXCGujonSGd5uf5hzKQ8UI=@vger.kernel.org X-Gm-Message-State: AOJu0Yy0lH0XzlUJqFc8WnhVANiQTlWjUZtwWYg0+m8BO0ygUS9+iVqH ycqDPeUxNOOBjCu/5IUaw+FgouGzeQ0ykNMqAbzdSDDh7aRowpTciZfqtH+nRpVpAAyqXwz8Yol h2YiZBmWneXuAY58gDIWZ2M2AAPVq9fbDXu4dkAEGfWN+CxX6kYVm+cuZYtiBRVOK5kACubpgso U= X-Gm-Gg: AeBDiesrfplcPpNzwVOq8tnXW5GDC2fpSTdDeQv5evZrpaztOteubtjbprFmPX768uJ UYSvEChvKixhyB0gctfQfkpVVfEgmGTfofRtsEaTCiLx2vs335+I4+LL7ZzkbaG7NVtH3PtAq0J uvKAqq5fTwZz8cB0b52wA78pAWVatCFEdvNcBWJ4cZM0pDk91X9Qet8QBCZc1gYoyO/O6wfvnuZ 9ZdwA3G5ot20IKt/4Ju7jcCCX1tg27XvxLc3xZC5V78rs3QSESIPT6N5xN4x0O3gR402+1gU/aV OWkprY36LxbFOnRj2XofKd4nM3gaZ/n/Spx6/oCv7wCWU4lxZoLPi+sAXKx8xa9lQSAU7llqfPl iiXCeJtLxii+fiRz6YMWrScv55etxSjuudnPBnBBpMJ4aO4dLI0m8GWPVVPfTQLaTwRggPGNcrT ArmGraM9qu0y7TxeFQe9kZQUeZ/pvO X-Received: by 2002:a05:6a00:94e2:b0:7e8:3fcb:9b03 with SMTP id d2e1a72fcca58-82f8b531fe8mr21830127b3a.25.1776922790145; Wed, 22 Apr 2026 22:39:50 -0700 (PDT) X-Received: by 2002:a05:6a00:94e2:b0:7e8:3fcb:9b03 with SMTP id d2e1a72fcca58-82f8b531fe8mr21830100b3a.25.1776922789523; Wed, 22 Apr 2026 22:39:49 -0700 (PDT) Received: from [10.133.33.145] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-82f8ebe40dasm18765415b3a.40.2026.04.22.22.39.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Apr 2026 22:39:49 -0700 (PDT) Message-ID: Date: Thu, 23 Apr 2026 13:39:43 +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: Fix incorrect frequency decrease due to stale target To: Lifeng Zheng , rafael@kernel.org, viresh.kumar@linaro.org, stratosk@semaphore.gr Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linuxarm@huawei.com, zhanjie9@hisilicon.com, lihuisong@huawei.com, yubowen8@huawei.com, zhangpengjie2@huawei.com, wangzhi12@huawei.com, linhongye@h-partners.com, zhongqiu.han@oss.qualcomm.com References: <20260421123545.1745998-1-zhenglifeng1@huawei.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <20260421123545.1745998-1-zhenglifeng1@huawei.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Authority-Analysis: v=2.4 cv=f4Z4wuyM c=1 sm=1 tr=0 ts=69e9b0a6 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=i0EeH86SAAAA:8 a=3wOXrwv6UN5-Hd3-6V8A:9 a=QEXdDO2ut3YA:10 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNDIzMDA1MCBTYWx0ZWRfX5GeloH3PDZfv 8yp7cbtxNbyVRNFNmNmPsv1IhEHXIzybJRVryoVIo3dte9h4gvJ5UNHdT0sLowEzHEEZ3eH9ofi cEyQmatXaWuUH5fmk0R1Rhg5EFgSO5klJJNXO0ZBTRhGYU4PL84HD8jQVOCEOM9TmDjaLic1kJc XFrMvW3LXHOLVqQltsZBf9a3hRlldCbLsARAntFp59pqeibAdE6SvcZ2Jk09QSaRG8QqPJx07oD q5HmvGQQyDFwLcbVjqkBAQJaqddP42uHyH/kh9HLUDwqP+eChX9hoXwIaq2ykntAT9ohN2r1uUl gUawOmVd75yMxjeSNqG9yPavXEvlDuIeQ+AhDZvbdW48UmrUm56ENN+045xuwblMpW+6PhaBsrE 0Pcbhrwxy08kjkAd9OoD+ghjNTk2W43Phke83gs/iHTrHGOd+hxOwEYdQYr7FmmUj+EW/gbot1O yQEj3ZDtfxtSboaNKDg== X-Proofpoint-GUID: WPNaivwVbjkYtiXdQKAWiSokjV_20Eit X-Proofpoint-ORIG-GUID: WPNaivwVbjkYtiXdQKAWiSokjV_20Eit 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-04-23_01,2026-04-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 phishscore=0 bulkscore=0 malwarescore=0 clxscore=1015 spamscore=0 suspectscore=0 adultscore=0 priorityscore=1501 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604200000 definitions=main-2604230050 On 4/21/2026 8:35 PM, Lifeng Zheng wrote: > In cs_dbs_update(), the requested frequency is decremented by one freq_step > for each idle period. However, this can cause divergence between > 'requested_freq' (target for current update) and 'dbs_info->requested_freq' > (target from previous update). > > When the load crosses up_threshold or down_threshold, the decision on > whether to increase or decrease frequency should be based on the *previous* > target (dbs_info->requested_freq), not the current one. Otherwise, the > update step may be skipped entirely if the current target has already hit a > boundary due to prior adjustments. > > Ensure that frequency scaling decisions are made using the correct > historical target, fixing cases where frequency fails to decrease despite > sustained idle periods. > > Fixes: 00bfe05889e9 ("cpufreq: conservative: Decrease frequency faster for deferred updates") > Signed-off-by: Lifeng Zheng Hi Lifeng, Thanks for the patch. May I know would this ignore conservative idle decay when the previous requested frequency was policy->max? Scenario: Increase path, previous target at max, with idle compensation; the original code does not have the same behavior as the current patch. Initial state: policy->max = 2000 MHz policy->min = 200 MHz dbs_info->requested_freq = 2000 MHz (= policy->max) hardware frequency = 2000 MHz idle_periods = 2 load = 90% (> up_threshold=80) 1.Original code Step 1: requested_freq = dbs_info->requested_freq = 2000 Step 2: [idle_periods block] freq_steps = 2 * 100 = 200 2000 > (200 + 200) = 400 ? YES requested_freq = 2000 - 200 = 1800 Step 3: [increase path] if (requested_freq == policy->max) -> 1800 == 2000 ? NO -> fall through Step 4: requested_freq += freq_step requested_freq = 1800 + 100 = 1900 Step 5: __cpufreq_driver_target(policy, 1900, HE) -> hardware = 1900 MHz Step 6: dbs_info->requested_freq = 1900 Result: hardware 2000 -> *1900 MHz* (net 1-step decrease) 2.Current Patch Step 1: requested_freq = 2000 Step 2: [idle_periods block] -> requested_freq = 1800 Step 3: if (dbs_info->requested_freq == policy->max) -> 2000 == 2000 ? YES -> goto out Step 4: hardware stays at 2000 MHz, dbs_info->requested_freq stays at 2000 Result: hardware stays at *2000 MHz* (no change) > --- > drivers/cpufreq/cpufreq_conservative.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c > index df01d33993d8..f3c3b54e4bf8 100644 > --- a/drivers/cpufreq/cpufreq_conservative.c > +++ b/drivers/cpufreq/cpufreq_conservative.c > @@ -104,7 +104,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > dbs_info->down_skip = 0; > > /* if we are already at full speed then break out early */ > - if (requested_freq == policy->max) > + if (dbs_info->requested_freq == policy->max) > goto out; > > requested_freq += freq_step; > @@ -127,7 +127,7 @@ static unsigned int cs_dbs_update(struct cpufreq_policy *policy) > /* > * if we cannot reduce the frequency anymore, break out early > */ > - if (requested_freq == policy->min) > + if (dbs_info->requested_freq == policy->min) > goto out; > > if (requested_freq > freq_step) -- Thx and BRs, Zhongqiu Han