Commit 42a2a96c authored by Sultan Alsawaf (unemployed)'s avatar Sultan Alsawaf (unemployed) Committed by Wentao Guan
Browse files

cpufreq: schedutil: Fix superfluous updates caused by need_freq_update

stable inclusion
from stable-v6.6.76
commit 50bcea7af9240b678caf37c5f68087f42924ff9c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IBW08Q

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=50bcea7af9240b678caf37c5f68087f42924ff9c



--------------------------------

[ Upstream commit 8e461a1cb43d69d2fc8a97e61916dce571e6bb31 ]

A redundant frequency update is only truly needed when there is a policy
limits change with a driver that specifies CPUFREQ_NEED_UPDATE_LIMITS.

In spite of that, drivers specifying CPUFREQ_NEED_UPDATE_LIMITS receive a
frequency update _all the time_, not just for a policy limits change,
because need_freq_update is never cleared.

Furthermore, ignore_dl_rate_limit()'s usage of need_freq_update also leads
to a redundant frequency update, regardless of whether or not the driver
specifies CPUFREQ_NEED_UPDATE_LIMITS, when the next chosen frequency is the
same as the current one.

Fix the superfluous updates by only honoring CPUFREQ_NEED_UPDATE_LIMITS
when there's a policy limits change, and clearing need_freq_update when a
requisite redundant update occurs.

This is neatly achieved by moving up the CPUFREQ_NEED_UPDATE_LIMITS test
and instead setting need_freq_update to false in sugov_update_next_freq().

Fixes: 600f5bad ("cpufreq: schedutil: Don't skip freq update when limits change")
Signed-off-by: default avatarSultan Alsawaf (unemployed) <sultan@kerneltoast.com>
Reviewed-by: default avatarChristian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/20241212015734.41241-2-sultan@kerneltoast.com


Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
(cherry picked from commit 50bcea7af9240b678caf37c5f68087f42924ff9c)
Signed-off-by: default avatarWentao Guan <guanwentao@uniontech.com>
parent fd64e86d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -83,7 +83,7 @@ static bool sugov_should_update_freq(struct sugov_policy *sg_policy, u64 time)

	if (unlikely(sg_policy->limits_changed)) {
		sg_policy->limits_changed = false;
		sg_policy->need_freq_update = true;
		sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
		return true;
	}

@@ -96,7 +96,7 @@ static bool sugov_update_next_freq(struct sugov_policy *sg_policy, u64 time,
				   unsigned int next_freq)
{
	if (sg_policy->need_freq_update)
		sg_policy->need_freq_update = cpufreq_driver_test_flags(CPUFREQ_NEED_UPDATE_LIMITS);
		sg_policy->need_freq_update = false;
	else if (sg_policy->next_freq == next_freq)
		return false;