public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Shawn Guo <shawnguo2@yeah.net>
To: "Rafael J . Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>
Cc: Qais Yousef <qyousef@layalina.io>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	Shawn Guo <shawnguo@kernel.org>,
	stable@vger.kernel.org
Subject: Re: [PATCH] cpufreq: cap the default transition delay at 10 ms
Date: Wed, 10 Sep 2025 15:11:08 +0800	[thread overview]
Message-ID: <aMEkjGN9HlwURISR@dragon> (raw)
In-Reply-To: <20250910065312.176934-1-shawnguo2@yeah.net>

On Wed, Sep 10, 2025 at 02:53:12PM +0800, Shawn Guo wrote:
> From: Shawn Guo <shawnguo@kernel.org>
> 
> A regression is seen with 6.6 -> 6.12 kernel upgrade on platforms where
> cpufreq-dt driver sets cpuinfo.transition_latency as CPUFREQ_ETERNAL (-1),
> due to that platform's DT doesn't provide the optional property
> 'clock-latency-ns'.  The dbs sampling_rate was 10000 us on 6.6 and
> suddently becomes 6442450 us (4294967295 / 1000 * 1.5) on 6.12 for these
> platforms, because that the 10 ms cap for transition_delay_us was
> accidentally dropped by the commits below.
> 
>   commit 37c6dccd6837 ("cpufreq: Remove LATENCY_MULTIPLIER")
>   commit a755d0e2d41b ("cpufreq: Honour transition_latency over transition_delay_us")
>   commit e13aa799c2a6 ("cpufreq: Change default transition delay to 2ms")
> 
> It slows down dbs governor's reacting to CPU loading change
> dramatically.  Also, as transition_delay_us is used by schedutil governor
> as rate_limit_us, it shows a negative impact on device idle power
> consumption, because the device gets slightly less time in the lowest OPP.
> 
> Fix the regressions by adding the 10 ms cap on transition delay back.
> 
> Cc: stable@vger.kernel.org
> Fixes: 37c6dccd6837 ("cpufreq: Remove LATENCY_MULTIPLIER")
> Signed-off-by: Shawn Guo <shawnguo@kernel.org>
> ---
>  drivers/cpufreq/cpufreq.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index fc7eace8b65b..36e0c85cb4e0 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -551,8 +551,13 @@ unsigned int cpufreq_policy_transition_delay_us(struct cpufreq_policy *policy)
>  
>  	latency = policy->cpuinfo.transition_latency / NSEC_PER_USEC;
>  	if (latency)
> -		/* Give a 50% breathing room between updates */
> -		return latency + (latency >> 1);
> +		/*
> +		 * Give a 50% breathing room between updates.
> +		 * And cap the transition delay to 10 ms for platforms
> +		 * where the latency is too high to be reasonable for
> +		 * reevaluating frequency.
> +		 */
> +		return min(latency + (latency >> 1), 10 * MSEC_PER_SEC);

I guess it's more correct to use USEC_PER_MSEC instead, even if both
have the value 1000.  Will fix in v2.

Shawn

>  
>  	return USEC_PER_MSEC;
>  }
> -- 
> 2.43.0
> 


  reply	other threads:[~2025-09-10  7:11 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-10  6:53 [PATCH] cpufreq: cap the default transition delay at 10 ms Shawn Guo
2025-09-10  7:11 ` Shawn Guo [this message]
2025-09-12 10:41 ` Rafael J. Wysocki
2025-09-12 13:07   ` Shawn Guo
2025-09-14 17:43     ` Qais Yousef
2025-09-15  7:29       ` Shawn Guo
2025-09-15 10:02         ` Qais Yousef
2025-09-15 12:20           ` Shawn Guo
2025-09-15 13:18         ` Rafael J. Wysocki
2025-09-16  1:52           ` Shawn Guo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aMEkjGN9HlwURISR@dragon \
    --to=shawnguo2@yeah.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=qyousef@layalina.io \
    --cc=rafael@kernel.org \
    --cc=shawnguo@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=viresh.kumar@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox