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 D81A9347507 for ; Fri, 13 Mar 2026 07:46:15 +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=1773387977; cv=none; b=g0t4xN/iEMbFT9aXY6v6W06LutvQsbx0ChkaXa5Bemp/c9RhGXoSXqMGO/E3A+l5dE03ahKb2GJLT144lqN+OPpdBQ18MgBqy+lfE3yETRoOKu93J9cZodLSMQ0nI2GO9EVujbTrbnICEEbfW9EMmx79CY/TbY9LV8rYPJMeFck= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773387977; c=relaxed/simple; bh=DwsNzm/8umZoU2yzq6nEGCvDC6V/+GpxI2gZHBpjzG8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iXY7HH7uhIigGfPfvAOAPeMvoUeCy5uH+mF67JaAONsfCOjDB6feMMRipD/p8Bd1jtRlwyepx2Ujek01/SDHs1x40/P9Uk1GraC3vDnONkJZTDR7/WN2zLt1y34hTjjLwnJ6/Cj27ViDPW7f0FmYxqhMHWGBbzZRO6GCPqhfLfk= 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=Zp7VlQHx; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=BpS34Eo0; 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="Zp7VlQHx"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="BpS34Eo0" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62D5teOW3844102 for ; Fri, 13 Mar 2026 07:46:15 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= MKXWuhbjCVKuOeOL9GK+KdDaxwdFjNW9tU6NIKF7NXM=; b=Zp7VlQHxHBa0ac4l PIsS6mdr95epoENf8VTt8BFDN+CWdZwOr7X487eCZfs/UmYuLUeT1hbZuwGQz1X1 PN/ONCWXnKlUWfzCd7aabpFuPdrpRB7FUWxdUV14pcoR+VnnL3zVeAGJ3EvoS2ew mnhzlql1YSIpsQmj6goTdTXRQ1EdLZ+AY40PCz5Lx98k7XTXnRogvI3pV/RONVSr 6jvRxWCkQ0+pnu5bPCGHAKydb2Qdz06dXq/GaHj+4pv1mI30PbRTvezI8QhD9ifw x2DfR7a+EQaNm5/hrratcbvPNSMOlI1mWncvL6XdpVYoRhApEmy9LeUvkodxx9Pf yod9Eg== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4cuh54w0gt-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 13 Mar 2026 07:46:14 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2aecd4f7ca1so5703795ad.2 for ; Fri, 13 Mar 2026 00:46:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773387974; x=1773992774; 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=MKXWuhbjCVKuOeOL9GK+KdDaxwdFjNW9tU6NIKF7NXM=; b=BpS34Eo01hd+bCqRo0FS6oT8u9uEHAq4K8iSWCKtLzuWcgBdSIjpqtWDkTg3dYw1+m kG5QCgJ5qsZ9ThSRq2ftp2vB7M8DkIK04wAn2fqkAa7VLOpFNgJ4Xs4hhqBwgVdcNE1t B6cd33vA3QFCMc55xuA0+9n6XAkFjvjdbwc3BeIK5LSLswJceiICOFyiCtCoKKIEexrx SkVwMiJrkbVPISiDIUG/VehMrPXlT7I2EcOECYtE+19ZhiUeIyuJnMJg+iF45LOp92I2 shiEg8HlwlG2C+WpWpMtDNeLQZ0h082FEEnCa5e2v7KG8BKwM0aT4HlRIymQonCnra4F gzIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773387974; x=1773992774; 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=MKXWuhbjCVKuOeOL9GK+KdDaxwdFjNW9tU6NIKF7NXM=; b=K5EB1gH5Cy3RFKDkLQnl8BTcD+xPFXnKKJSJ9LjilhbURA9kP+kPZAXRUEA4kaJs0E QQF12MVUHHekFyAHDBA+l/yVKIUS96//4Wr9v34cc2GVlqtJ9RWe5+MM9U0tiUzc9roN P5Kt7wWRQ4zmX4OLFLrGY+a7BT2ToZSlhgP22eQ8j9NvKTSpDgJntemICoc2lNg6/Mc2 1Q4rYkrrpxShKtvMzAm/vtq2cx74AHWY6Va2E2YFK5RpXP7tVW/pGab7m7fdMiFSX3oZ El8OORT9g5KplK+Esq8pDVZBgYH5In2t7wUf3NbskLK5+v9VfqRbsUIjTmL0SBlpBUMl u1VQ== X-Forwarded-Encrypted: i=1; AJvYcCUr6TG9j9U5znj7OYLSslu+rrMlV+Qw+dMCcmUsNxSieLjzNdRCyYUbHNwZzBPBAweO4ONwKaxq59pRa2Y=@vger.kernel.org X-Gm-Message-State: AOJu0YwZrwLVUC8CgHBfChOD9yubFnhjfCK1MHZEl0TNhPo60aU//zNC lGRzgpbOD/AeW77uGZNm6teA/56cZxfV7BUnPUyVur9TU/gSQ1xVTrIa9MGUueEYdaeGLV79kG1 teewl6mAOM4Uc+MAbwgT6WanLIm9okdDATMO28tnFjmjgVUtEKW3+a0inQLjo3ghmScg= X-Gm-Gg: ATEYQzxlzLedONGbLb56fmNaFC0aWMbC2N82EJWmVopZlJa02PwXonBvsqjFso7hEBa AJusbOXtdLwflmXb8TlRv4Zb8RXBOhzbdVBvGuMnyTXhtpoz30Phl+Fcy4UTvM9lOOYQMPSJFKn FDpRsQM40KWcJhd7n4kqx8rlJxt7o/Ofe7vTf++bs/SNZcrHXkhbDwbhSf+cpVS22hTcVuEhLh4 EleHTb145CskmbeNekS8sF0V3u0Y2UhjXSs3F5wthh5eKgwpfYEix4JBjT0c02NZor1eMPDp9zs dyZXbpPVKg/B6APOlFeZqh5qzC1rH6h4m5iuaewzPSJ1HaGK22BbNpxRbiI0J+kCwyaWWeEzq8U yqmYANhNcgMlU3Gd7aEW694IZZh59D2jDTRVIX2Wmz7sfiwyZJP0mrVDM/Wu6vqmsPzVushGvfg /upT57nCunpEgg0tar X-Received: by 2002:a17:902:ebcd:b0:2ae:4d93:ba36 with SMTP id d9443c01a7336-2aeca95946fmr21926155ad.11.1773387973824; Fri, 13 Mar 2026 00:46:13 -0700 (PDT) X-Received: by 2002:a17:902:ebcd:b0:2ae:4d93:ba36 with SMTP id d9443c01a7336-2aeca95946fmr21925815ad.11.1773387973258; Fri, 13 Mar 2026 00:46:13 -0700 (PDT) Received: from [10.133.33.57] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2aece56ca0csm14205345ad.4.2026.03.13.00.46.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 13 Mar 2026 00:46:12 -0700 (PDT) Message-ID: <0a154e14-8446-4b6a-b0c6-4164f942bcf0@oss.qualcomm.com> Date: Fri, 13 Mar 2026 15:46:08 +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 Cc: "Rafael J. Wysocki" , linux-pm@vger.kernel.org, Vincent Guittot , Lifeng Zheng , linux-kernel@vger.kernel.org, zhongqiu.han@oss.qualcomm.com References: <05feb9ed-3257-452e-98e9-89637431a347@oss.qualcomm.com> Content-Language: en-US From: Zhongqiu Han In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Proofpoint-GUID: Ie-r2kW72mmJ3F_kj-rKZlozQQqJ-EfC X-Authority-Analysis: v=2.4 cv=BNG+bVQG c=1 sm=1 tr=0 ts=69b3c0c6 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=kGvhgXOsEy1v87aZk24A:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-ORIG-GUID: Ie-r2kW72mmJ3F_kj-rKZlozQQqJ-EfC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzEzMDA2MCBTYWx0ZWRfX0DzXpFO6A2vM otE3nGI+PXy9lxq0jKymp5sgeVQv5ua2Fmdoe3Y+7s+PpZp1utstPj760T/S7Im6Nug/v8Cc8eT +ePDlFVRyixlKhLSMJVCp4aH2Vq/GLyEhXWDV9tf3o89DkXaZUPG7NpbCTnCJn1IR1tvJmciS62 tISCvyDHqbHfTRNRudfE8JCOlS74qiimeE6Ctix9fFmNcKk+6sFKGBy2JOyvoLruiSFSiOFLwMJ NsRORKUakNZd814vJv+NsU/zgXOe5BhmsAgjb0zmGsiQTNLJuiRULNdGI4Kzm47jpJL6YbI4xUu LickPbbYJ10I+rK/q6+BfeQkx8cQch+UynVWUV8y7WHmkJQRS1jJHp4gLta5MG8G3DhGeIW3KGf mFHdhSdj6OT76i9hJL1gBlLLP7nxfVyraxmCeZDQcautJZvqBS0dIIXgOO09ipZoiLPPqKWbj89 th+vCUGFwAyqohQJNDQ== 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-13_01,2026-03-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 bulkscore=0 lowpriorityscore=0 malwarescore=0 priorityscore=1501 impostorscore=0 adultscore=0 phishscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603130060 On 3/12/2026 6:27 PM, Viresh Kumar wrote: > On 10-03-26, 21:17, Zhongqiu Han wrote: >> 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")? > > Thanks for pointing this, I missed this change. > >> 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. > > Its the opposite I think. The governor stays within a range and never > goes to a higher or lower frequency. This is how I think this happens: > - Lets say frequencies are from 1GHz to 2GHz with a gap of 200 MHz. > - Lets say the frequency is 1 GHz now and the step size is 100 MHz. > - conservative governor will try to change the freq to 1.1 GHz and end > up selecting 1 GHz only (due to CPUFREQ_RELATION_H, highest freq > below 1.1 GHz). > - With my patch, we will keep resetting to 1 GHz (cur freq) and never > change freq. > - With a recorded requested_freq, we will move to 1.1 GHz (actual 1 > GHz), but a subsequent call will go for 1.2 GHz. > > Here is another idea, once everyone agrees I can send this formally: > Hi Viresh, Thanks a lot for the detailed explanation — that makes sense. I agree that my earlier concern was not entirely accurate, and your explanation clarifies the behavior well. Overall, this patch looks like a good balance between avoiding stalling with small freq_step on discrete frequency tables and fixing requested_freq drift from policy->cur due to out-of-band frequency changes. LGTM from my side. > diff --git a/drivers/cpufreq/cpufreq_conservative.c b/drivers/cpufreq/cpufreq_conservative.c > index e0e847764511..df01d33993d8 100644 > --- a/drivers/cpufreq/cpufreq_conservative.c > +++ b/drivers/cpufreq/cpufreq_conservative.c > @@ -313,6 +313,17 @@ static void cs_start(struct cpufreq_policy *policy) > dbs_info->requested_freq = policy->cur; > } > > +static void cs_limits(struct cpufreq_policy *policy) > +{ > + struct cs_policy_dbs_info *dbs_info = to_dbs_info(policy->governor_data); > + > + /* > + * The limits have changed, so may have the current frequency. Reset > + * requested_freq to avoid any unintended outcomes due to the mismatch. > + */ > + dbs_info->requested_freq = policy->cur; > +} > + > static struct dbs_governor cs_governor = { > .gov = CPUFREQ_DBS_GOVERNOR_INITIALIZER("conservative"), > .kobj_type = { .default_groups = cs_groups }, > @@ -322,6 +333,7 @@ static struct dbs_governor cs_governor = { > .init = cs_init, > .exit = cs_exit, > .start = cs_start, > + .limits = cs_limits, > }; > > #define CPU_FREQ_GOV_CONSERVATIVE (cs_governor.gov) > diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c > index 36eb7aee4bcd..acf101878733 100644 > --- a/drivers/cpufreq/cpufreq_governor.c > +++ b/drivers/cpufreq/cpufreq_governor.c > @@ -563,6 +563,7 @@ EXPORT_SYMBOL_GPL(cpufreq_dbs_governor_stop); > > void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy) > { > + struct dbs_governor *gov = dbs_governor_of(policy); > struct policy_dbs_info *policy_dbs; > > /* Protect gov->gdbs_data against cpufreq_dbs_governor_exit() */ > @@ -574,6 +575,8 @@ void cpufreq_dbs_governor_limits(struct cpufreq_policy *policy) > mutex_lock(&policy_dbs->update_mutex); > cpufreq_policy_apply_limits(policy); > gov_update_sample_delay(policy_dbs, 0); > + if (gov->limits) > + gov->limits(policy); > mutex_unlock(&policy_dbs->update_mutex); > > out: > diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h > index 168c23fd7fca..1462d59277bd 100644 > --- a/drivers/cpufreq/cpufreq_governor.h > +++ b/drivers/cpufreq/cpufreq_governor.h > @@ -138,6 +138,7 @@ struct dbs_governor { > int (*init)(struct dbs_data *dbs_data); > void (*exit)(struct dbs_data *dbs_data); > void (*start)(struct cpufreq_policy *policy); > + void (*limits)(struct cpufreq_policy *policy); > }; > > static inline struct dbs_governor *dbs_governor_of(struct cpufreq_policy *policy) > > -- Thx and BRs, Zhongqiu Han