From: "Rafael J. Wysocki" <rjw@rjwysocki.net>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org,
Pi-Cheng Chen <pi-cheng.chen@linaro.org>,
"Jon Medhurst (Tixy)" <tixy@linaro.org>,
open list <linux-kernel@vger.kernel.org>,
Steven Rostedt <rostedt@goodmis.org>
Subject: Re: [PATCH] cpufreq: Initialize the governor again while restoring policy
Date: Fri, 10 Jul 2015 02:05:18 +0200 [thread overview]
Message-ID: <5369372.r4v2a9W8l1@vostro.rjw.lan> (raw)
In-Reply-To: <20150709051024.GJ1805@linux>
On Thursday, July 09, 2015 10:40:24 AM Viresh Kumar wrote:
> On 09-07-15, 02:33, Rafael J. Wysocki wrote:
> > > We also missed marking policy->governor as NULL while restoring the
> > > policy. Because of that, we call __cpufreq_governor(CPUFREQ_GOV_LIMITS)
> >
> > How exactly does that happen?
>
> Should have mentioned that in detail, sorry for being lazy. Hopefully
> this will look better:
OK, applied (with some minor changelog fixup), thanks!
> ---------------------------8<---------------------------
>
> Message-Id: <5f17361741c009a7f0d8488f7f94bab80d9317fd.1436418101.git.viresh.kumar@linaro.org>
> From: Viresh Kumar <viresh.kumar@linaro.org>
> Date: Wed, 8 Jul 2015 10:45:53 +0530
> Subject: [PATCH V2] cpufreq: Initialize the governor again while restoring policy
>
> When all CPUs of a policy are hot-unplugged, we EXIT the governor but
> don't mark policy->governor as NULL. This was done in order to keep last
> used governor's information intact in sysfs, while the CPUs are offline.
>
> But we also marking policy->governor as NULL while restoring the policy.
>
> Because policy->governor still points to the last governor while policy
> is restored, following sequence of event happens:
> - cpufreq_init_policy() called while restoring policy
> - find_governor() matches last_governor string for present governors and
> returns last used governor's pointer, say ondemand. policy->governor
> already has the same address, unless the governor was removed in
> between.
> - cpufreq_set_policy() is called with both old/new policies governor set
> as ondemand.
> - Because governors matched, we skip governor initialization and return
> after calling __cpufreq_governor(CPUFREQ_GOV_LIMITS).
But this sounds fragile in principle. What's the benefit from skipping the
governor initialization in that case?
> Because the
> governor wasn't initialized for this policy, it returned -EBUSY.
> - cpufreq_init_policy() exits the policy on this error, but doesn't
> destroy it properly (should be fixed separately).
> - And so we enter a scenario where the policy isn't completely
> initialized but used.
>
> Fix this by setting policy->governor to NULL while restoring the policy.
>
> Reported-and-tested-by: Pi-Cheng Chen <pi-cheng.chen@linaro.org>
> Reported-and-tested-by: "Jon Medhurst (Tixy)" <tixy@linaro.org>
> Tested-by: Steven Rostedt <rostedt@goodmis.org>
> Fixes: 18bf3a124ef8 ("cpufreq: Mark policy->governor = NULL for inactive policies")
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2: Detailed changelog
>
> drivers/cpufreq/cpufreq.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index b612411655f9..2c22e3902e72 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -1132,6 +1132,7 @@ static struct cpufreq_policy *cpufreq_policy_restore(unsigned int cpu)
>
> down_write(&policy->rwsem);
> policy->cpu = cpu;
> + policy->governor = NULL;
> up_write(&policy->rwsem);
> }
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
next prev parent reply other threads:[~2015-07-09 23:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-08 5:53 Viresh Kumar
2015-07-08 6:02 ` Pi-Cheng Chen
2015-07-08 9:27 ` Jon Medhurst (Tixy)
2015-07-08 9:29 ` Viresh Kumar
2015-07-09 0:33 ` Rafael J. Wysocki
2015-07-09 5:10 ` Viresh Kumar
2015-07-10 0:05 ` Rafael J. Wysocki [this message]
2015-07-10 3:38 ` Viresh Kumar
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=5369372.r4v2a9W8l1@vostro.rjw.lan \
--to=rjw@rjwysocki.net \
--cc=linaro-kernel@lists.linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=pi-cheng.chen@linaro.org \
--cc=rostedt@goodmis.org \
--cc=tixy@linaro.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
all inboxes | Powered by JetHome®