[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190722004016.GD1607@sasha-vm>
Date: Sun, 21 Jul 2019 20:40:16 -0400
From: Sasha Levin <sashal@...nel.org>
To: "Rafael J. Wysocki" <rafael.j.wysocki@...el.com>
Cc: linux-kernel@...r.kernel.org, stable@...r.kernel.org,
Viresh Kumar <viresh.kumar@...aro.org>,
linux-pm@...r.kernel.org
Subject: Re: [PATCH AUTOSEL 5.2 190/249] cpufreq: Avoid calling
cpufreq_verify_current_freq() from handle_update()
On Tue, Jul 16, 2019 at 11:25:00AM +0200, Rafael J. Wysocki wrote:
>On 7/15/2019 3:45 PM, Sasha Levin wrote:
>>From: Viresh Kumar <viresh.kumar@...aro.org>
>>
>>[ Upstream commit 70a59fde6e69d1d8579f84bf4555bfffb3ce452d ]
>>
>>On some occasions cpufreq_verify_current_freq() schedules a work whose
>>callback is handle_update(), which further calls cpufreq_update_policy()
>>which may end up calling cpufreq_verify_current_freq() again.
>>
>>On the other hand, when cpufreq_update_policy() is called from
>>handle_update(), the pointer to the cpufreq policy is already
>>available, but cpufreq_cpu_acquire() is still called to get it in
>>cpufreq_update_policy(), which should be avoided as well.
>>
>>To fix these issues, create a new helper, refresh_frequency_limits(),
>>and make both handle_update() call it cpufreq_update_policy().
>>
>>Signed-off-by: Viresh Kumar <viresh.kumar@...aro.org>
>>[ rjw: Rename reeval_frequency_limits() as refresh_frequency_limits() ]
>>[ rjw: Changelog ]
>>Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
>>Signed-off-by: Sasha Levin <sashal@...nel.org>
>>---
>> drivers/cpufreq/cpufreq.c | 26 ++++++++++++++++----------
>> 1 file changed, 16 insertions(+), 10 deletions(-)
>>
>>diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>>index e84bf0eb7239..876a4cb09de3 100644
>>--- a/drivers/cpufreq/cpufreq.c
>>+++ b/drivers/cpufreq/cpufreq.c
>>@@ -1114,13 +1114,25 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp
>> return ret;
>> }
>>+static void refresh_frequency_limits(struct cpufreq_policy *policy)
>>+{
>>+ struct cpufreq_policy new_policy = *policy;
>>+
>>+ pr_debug("updating policy for CPU %u\n", policy->cpu);
>>+
>>+ new_policy.min = policy->user_policy.min;
>>+ new_policy.max = policy->user_policy.max;
>>+
>>+ cpufreq_set_policy(policy, &new_policy);
>>+}
>>+
>> static void handle_update(struct work_struct *work)
>> {
>> struct cpufreq_policy *policy =
>> container_of(work, struct cpufreq_policy, update);
>>- unsigned int cpu = policy->cpu;
>>- pr_debug("handle_update for cpu %u called\n", cpu);
>>- cpufreq_update_policy(cpu);
>>+
>>+ pr_debug("handle_update for cpu %u called\n", policy->cpu);
>>+ refresh_frequency_limits(policy);
>> }
>> static struct cpufreq_policy *cpufreq_policy_alloc(unsigned int cpu)
>>@@ -2392,7 +2404,6 @@ int cpufreq_set_policy(struct cpufreq_policy *policy,
>> void cpufreq_update_policy(unsigned int cpu)
>> {
>> struct cpufreq_policy *policy = cpufreq_cpu_acquire(cpu);
>>- struct cpufreq_policy new_policy;
>> if (!policy)
>> return;
>>@@ -2405,12 +2416,7 @@ void cpufreq_update_policy(unsigned int cpu)
>> (cpufreq_suspended || WARN_ON(!cpufreq_update_current_freq(policy))))
>> goto unlock;
>>- pr_debug("updating policy for CPU %u\n", cpu);
>>- memcpy(&new_policy, policy, sizeof(*policy));
>>- new_policy.min = policy->user_policy.min;
>>- new_policy.max = policy->user_policy.max;
>>-
>>- cpufreq_set_policy(policy, &new_policy);
>>+ refresh_frequency_limits(policy);
>> unlock:
>> cpufreq_cpu_release(policy);
>
>I don't think this is suitable for -stable.
I've dropped it, thanks!
--
Thanks,
Sasha
Powered by blists - more mailing lists