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 B388D346E51 for ; Fri, 19 Jun 2026 10:50:26 +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=1781866228; cv=none; b=ItqG2rkC33iakIVkrWWrjm7CGIT5dRYmZOkkUXzx/3raNtWMbbQODtKZmhHiMYtBagL9MEWU41pzhIRKz70X5Dsb4g9uV6ODLDfP9BIrZkxtNBJMSaRwbo8r+MDYi6jttgogHnxTPgn7RtEBzLPpQEFJaWKNFZeP2sYvjnXd1sA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781866228; c=relaxed/simple; bh=aXaJ2KA0ZXlmXHwCabUpyttnqN0Q87S3cz3deFTQOqc=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WNSAgn3oRJ71fFzzjI/OmTgj57/4iwemchZt0sQL3o79oqupsI2HFvk+HytGQVmsPi0kJiLGZyRlhGnVJqK2/ni3yIeMBipg6IRDces7Z4V/ZSs/ZhVLDxkKAuJTDYlNdAwJ2+b1xnDXE14OHc80yxeiTjD3W9w4HDypi28j+Ck= 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=Fl2dq1Pv; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Pm98oGc6; 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="Fl2dq1Pv"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Pm98oGc6" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65J7OipT3707481 for ; Fri, 19 Jun 2026 10:50:26 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= Dyf9Y0mN0Kii4oP1x4MGlaqQbVYrCsX66J86g6nZm08=; b=Fl2dq1PvIYye9K3f Guo3YgdPLnqSgzKYCbT4UStSmUOyXdPeImEqSqqdt0grIQGspOwcKCmFezRsgBdq UFqDbsIEVXKakNPF/IY4pf5HsgArAb3Mlegc6+tBZPD4dMCMekEJwKTkR2UwEwbL k15P88S+GicZBZuGxqFXl4MGUHdjDL1zjV0fxfpE5mFiz0WK3Mhm5dAy4PucJ+A+ d5u679tQxcclawra7H8b6pl+1cKc6gRbHG5pBdB8U0OC/O1CO2qmHQYyCMBNBKc6 mOxQ6XoYqxSGz20R3cSzXXN20RAt9wBYJWN75OAsmJUiq9nQddW9DgKgTqqc1Pdm njSS6w== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4evp672tv0-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Fri, 19 Jun 2026 10:50:25 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-37c64f7ff48so2373941a91.2 for ; Fri, 19 Jun 2026 03:50:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781866225; x=1782471025; 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=Dyf9Y0mN0Kii4oP1x4MGlaqQbVYrCsX66J86g6nZm08=; b=Pm98oGc6Q3fD4Vrv/4p3BhTUeUeysopb3Egx3PpoyMH8QJ8MOGYvlf60TO1J0GdNAj CjdrhHu53Ac/MGzE93rg+Vy95zVVb84MqdbmoatqqSL7IRs3BVQHuscP8RJ9J1XXUxN0 1JMEW/9m4AYgVhCku3GSncqo3E+PuasvewI5P9fIUbyk5E7RhRpS3CywP8E7Ydz3yUO8 xneaQMkRCfFMM73k1RL9xS9sSR19yOGkrAiz1eKwCC624o5qWvy6g1q+hoMJFDXWuTkC DDmFV0fowKhYnq76eyF33mfG7Oua8O99KFG9QPtuiLOJVstEY1hYR517S/arlDxdPw1e 5ubg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781866225; x=1782471025; 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=Dyf9Y0mN0Kii4oP1x4MGlaqQbVYrCsX66J86g6nZm08=; b=ax1pQjJQorUNca822FaBxtFF9na5KYWnOlLI6qGYeGYR/wpeDQLT7m31oOW2Uf29NU rtmXK8toS6HYKGLbXkDnRlFLmyI09E7Ryc1f+x+2Sdp2PBA5AwhBUf02o2HGD+RZBVGf fcIpRSfOBBK+B6I/9PtDmXQpkB3/fIreXxzCKkmiQi2g0yBRX2okw5LUstp/n3UnCF72 AeOH8ZcfAm5Med7FY4fQ5VlA4+jByT0VWpnLGp4/tJ8nvy0CBnLXpgk9+k911Y/f+1N1 5/PCTKb5SiZ3WZO6yg3q8nRVvKeEHKhr6vlee8pDoVwncE/1TaMaBo7igRIckWgGg9Zr w+TA== X-Gm-Message-State: AOJu0YwV24kZMOFnFF/FNbTw6Tff85aNVwgUSF6+PY/efmj4eZr/j9C4 QIYYfKQ/GlHf+DVz5NlBd3z177eRuf9cNuyg7/qnPo9RZeTz4BoiMQpNVxPkNTqZ8PUvw4Q47Ai IfQeE126/tPm/ikGbF4PI6HL7ckjnCUOSwA1zlbc5xPkds1dm1INgkKRolp4+p6j0298rRf79Z4 cBeQ== X-Gm-Gg: AfdE7ckI+9tF2jUkojwxlWtSNuCT+gKgIG8+SHgkZWc8uunAKKCs1yZqo6rIDkZFH/o JEEKqhtcQFaKCts1DKARowAoG8iSi3K1uUFT+TvAD1TxruJmYlkIb/dO9zRZImV3GEYtTvWZwaX Vgfbqfr+oxBE9DrCxcptyxXAz0YFQpOhb/op7UinKRwiyvQNrhKh4oSX8SUXarRo5X+ktDfYNR5 VDzFcwgSO5jZWDA/sNcTxSBRJRNQu1lMVF+kL0BmM3gdBWITZWOf15VKdWs1xuSxQpG8iLzqDOr GAB3G0lpVq7DKTdBKEZHEROSP6oixNkshfd1AciXt1E80nDFEkoXJmxp+DevM1iiCzYKxWCQNSl /aOt6tpmvjl+YLq7laHVAvgX8FLJENa9WG6lotYfDICT01wIHMgb1JIubucYBYgeS+u/hk3Zzi/ DyNtGRx/I= X-Received: by 2002:a17:90b:2686:b0:36b:71e6:3de8 with SMTP id 98e67ed59e1d1-37d1ea6759bmr2285382a91.24.1781866224900; Fri, 19 Jun 2026 03:50:24 -0700 (PDT) X-Received: by 2002:a17:90b:2686:b0:36b:71e6:3de8 with SMTP id 98e67ed59e1d1-37d1ea6759bmr2285352a91.24.1781866224436; Fri, 19 Jun 2026 03:50:24 -0700 (PDT) Received: from [10.133.33.106] (tpe-colo-wan-fw-bordernet.qualcomm.com. [103.229.16.4]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-37d153601c4sm2386774a91.3.2026.06.19.03.50.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Jun 2026 03:50:24 -0700 (PDT) Message-ID: <2421ef06-e0d7-4380-a51b-c3f500ed4b97@oss.qualcomm.com> Date: Fri, 19 Jun 2026 18:50:17 +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 v1] cpufreq: intel_pstate: Adjust the .adjust_perf() driver callback To: "Rafael J. Wysocki" , Linux PM Cc: LKML , Viresh Kumar , Srinivas Pandruvada , Christian Loehle , Peter Zijlstra , Vincent Guittot , zhongqiu.han@oss.qualcomm.com References: <14060154.uLZWGnKmhe@rafael.j.wysocki> Content-Language: en-US From: Zhongqiu Han In-Reply-To: <14060154.uLZWGnKmhe@rafael.j.wysocki> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-ORIG-GUID: 2veXu163_7El0hdpzCNOvNz2AWVhMTF5 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjE5MDEwMSBTYWx0ZWRfXxVYfHNJ2Qtg9 eh25QPdbqHojBKTPLqViVR+0kV2KdAs2tZND77LMPGPZgUw9DQa2J0ionX4B4GYlcnRcYOLcQgH Ig4lihSz/U2kVoTFzjHnzp8U6+Pg7hUIi1SPdg4TEqVQOSYDUoJxHdrzrli2Hv1eATOVUXj8tYW AkSCrK5ZbWgs3JCw5bQ9PxysZ+ZixrlXWASf5Q6+GSvID+9cb7z53HgXDUAvcrN7POjkm2tAnCa C4hdwIzNmIeNNi+rDIef5oj+qpJ5/YU7fxPclB0pLu/IZ6LYpsH1b3LfkI2zcc55Nlo3K1t1c/j iFnDIkfjm98WL0sV4VpTTZMJdiw0kqV/2s2PWjyu4ntIOP/ILHC+UVHn4pDQhTk+xaw/r/YIiec UdyHfy4g43vJdpCMmKnjTizaM0+lpVInBd8kdwPudFaPAO6w5T86zycCm/s1t2LXONGV+bqZGEr 6FlJ4jJ7K5PHjI3gyZQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjE5MDEwMSBTYWx0ZWRfXyAIrji4ZcuAH e2o47uDcDWOtwWR5e7t1FQEn19yRZGfUhJIglRgg2VLzdoy7ZCumGbotWhxxZ11QK3PHqsWsezs igmEBqxdYRM+MHK+tEbeVfIDbvJoDzs= X-Proofpoint-GUID: 2veXu163_7El0hdpzCNOvNz2AWVhMTF5 X-Authority-Analysis: v=2.4 cv=TdOmcxQh c=1 sm=1 tr=0 ts=6a351ef1 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=nuhDOHQX5FNHPW3J6Bj6AA==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=YMgV9FUhrdKAYTUUvYB2:22 a=c92rfblmAAAA:8 a=QyXUC8HyAAAA:8 a=1a0ZiCl4u1-ptICwYMEA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf:22 a=GvGzcOZaWPEFPQC_NcjD:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-19_02,2026-06-18_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 impostorscore=0 spamscore=0 phishscore=0 malwarescore=0 clxscore=1015 suspectscore=0 bulkscore=0 priorityscore=1501 adultscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606190101 On 6/18/2026 12:14 AM, Rafael J. Wysocki wrote: > From: Rafael J. Wysocki > > In some cases, the processor may not actually stick to the "desired" > performance level programmed through the driver's .adjust_perf() > callback and may go above it, which may not be desirable (for instance, > there may be a UCLAMP_MAX limit set for the task currently running on > the given CPU which should be respected). > > Address that by adjusting the .adjust_perf() callback to take an > additional argument, max_perf, representing the maximum allowed > performance level of the CPU and update the intel_pstate driver to > take that argument into account as appropriate. > > Accordingly, adjust cpufreq_driver_adjust_perf() and the other existing > user of .adjust_perf(), which is the amd-pstate driver (but the behavior > of that driver is not changed). > > While at it, also update the cpufreq_driver_adjust_perf() > documentation to reflect this change and some previous code > changes that have not been taken into account in it. Looks reasonable overall. > > Signed-off-by: Rafael J. Wysocki > --- > drivers/cpufreq/amd-pstate.c | 1 + > drivers/cpufreq/cpufreq.c | 14 +++++++++----- > drivers/cpufreq/intel_pstate.c | 9 ++++++++- > include/linux/cpufreq.h | 2 ++ > kernel/sched/cpufreq_schedutil.c | 4 +++- > 5 files changed, 23 insertions(+), 7 deletions(-) > > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -781,6 +781,7 @@ static unsigned int amd_pstate_fast_swit > static void amd_pstate_adjust_perf(struct cpufreq_policy *policy, > unsigned long _min_perf, > unsigned long target_perf, > + unsigned long _max_perf, > unsigned long capacity) > { > u8 max_perf, min_perf, des_perf, cap_perf; > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2252,14 +2252,17 @@ EXPORT_SYMBOL_GPL(cpufreq_driver_fast_sw > * @policy: cpufreq policy object of the target CPU. > * @min_perf: Minimum (required) performance level (units of @capacity). > * @target_perf: Target (desired) performance level (units of @capacity). > + * @max_perf: Maximum (allowed) performance level (units of @capacity). > * @capacity: Capacity of the target CPU. > * > - * Carry out a fast performance level switch of @cpu without sleeping. > + * Carry out a fast performance level adjustment for the CPU represeted by represeted --> represented > + * @policy without sleeping. > * > * The driver's ->adjust_perf() callback invoked by this function must be > - * suitable for being called from within RCU-sched read-side critical sections > - * and it is expected to select a suitable performance level equal to or above > - * @min_perf and preferably equal to or below @target_perf. > + * suitable for calling from within RCU-sched read-side critical sections and > + * it is expected to program the proocessor to select suitable performance proocessor --> processor > + * levels betweem @min_perf and @max_perf inclusive and preferably close to betweem --> between > + * @target_perf going forward for the CPU represented by @policy. > * > * This function must not be called if policy->fast_switch_enabled is unset. > * > @@ -2271,9 +2274,10 @@ EXPORT_SYMBOL_GPL(cpufreq_driver_fast_sw > void cpufreq_driver_adjust_perf(struct cpufreq_policy *policy, > unsigned long min_perf, > unsigned long target_perf, > + unsigned long max_perf, > unsigned long capacity) > { > - cpufreq_driver->adjust_perf(policy, min_perf, target_perf, capacity); > + cpufreq_driver->adjust_perf(policy, min_perf, target_perf, max_perf, capacity); > } > > /** > --- a/drivers/cpufreq/intel_pstate.c > +++ b/drivers/cpufreq/intel_pstate.c > @@ -3241,6 +3241,7 @@ static unsigned int intel_cpufreq_fast_s > static void intel_cpufreq_adjust_perf(struct cpufreq_policy *policy, > unsigned long min_perf, > unsigned long target_perf, > + unsigned long max_perf, > unsigned long capacity) > { > struct cpudata *cpu = all_cpu_data[policy->cpu]; > @@ -3271,7 +3272,13 @@ static void intel_cpufreq_adjust_perf(st > if (min_pstate > cpu->max_perf_ratio) > min_pstate = cpu->max_perf_ratio; > > - max_pstate = min(cap_pstate, cpu->max_perf_ratio); > + max_pstate = cap_pstate; > + if (max_perf < capacity) > + max_pstate = DIV_ROUND_UP(cap_pstate * max_perf, capacity); > + > + if (max_pstate > cpu->max_perf_ratio) > + max_pstate = cpu->max_perf_ratio; > + > if (max_pstate < min_pstate) > max_pstate = min_pstate; > > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -379,6 +379,7 @@ struct cpufreq_driver { > void (*adjust_perf)(struct cpufreq_policy *policy, > unsigned long min_perf, > unsigned long target_perf, > + unsigned long max_perf, > unsigned long capacity); Sashiko also pointed out a potential Rust binding mismatch, which might be worth checking (the callback signature change may not be reflected in rust/kernel/cpufreq.rs): https://sashiko.dev/#/patchset/14060154.uLZWGnKmhe%40rafael.j.wysocki > > /* > @@ -624,6 +625,7 @@ unsigned int cpufreq_driver_fast_switch( > void cpufreq_driver_adjust_perf(struct cpufreq_policy *policy, > unsigned long min_perf, > unsigned long target_perf, > + unsigned long max_perf, > unsigned long capacity); > bool cpufreq_driver_has_adjust_perf(void); > int cpufreq_driver_target(struct cpufreq_policy *policy, > --- a/kernel/sched/cpufreq_schedutil.c > +++ b/kernel/sched/cpufreq_schedutil.c > @@ -50,6 +50,7 @@ struct sugov_cpu { > > unsigned long util; > unsigned long bw_min; > + unsigned long bw_max; > > /* The field below is for single-CPU policies only: */ > #ifdef CONFIG_NO_HZ_COMMON > @@ -232,6 +233,7 @@ static void sugov_get_util(struct sugov_ > util = effective_cpu_util(sg_cpu->cpu, util, &min, &max); > util = max(util, boost); > sg_cpu->bw_min = min; > + sg_cpu->bw_max = max; > sg_cpu->util = sugov_effective_cpu_perf(sg_cpu->cpu, util, min, max); > } > > @@ -484,7 +486,7 @@ static void sugov_update_single_perf(str > sg_cpu->util = prev_util; > > cpufreq_driver_adjust_perf(sg_policy->policy, sg_cpu->bw_min, > - sg_cpu->util, max_cap); > + sg_cpu->util, sg_cpu->bw_max, max_cap); > > sg_policy->last_freq_update_time = time; > } > > > > -- Thx and BRs, Zhongqiu Han