From: Xiaoguang Chen <chenxg.marvell@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: Xiaoguang Chen <chenxg@marvell.com>,
"cpufreq@vger.kernel.org" <cpufreq@vger.kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: [PATCH 1/2] cpufreq: Add governor operation ongoing flag
Date: Wed, 14 Aug 2013 15:36:20 +0800 [thread overview]
Message-ID: <CAFgnuDes_F7Q5CHbXKC=ndrn9Gr3PJfGj0QvDXA-FuGcq41CHQ@mail.gmail.com> (raw)
In-Reply-To: <CAKohpo=QKPvqUcQVsbbSQdWOOi5L-P2CBFzcfMsobs8uGpLkVw@mail.gmail.com>
2013/8/14 Viresh Kumar <viresh.kumar@linaro.org>:
> On 13 August 2013 12:39, Xiaoguang Chen <chenxg@marvell.com> wrote:
>> __cpufreq_governor operation needs to be executed one by one.
>> If one operation is ongoing, the other operation can't be executed.
>> If the order is not guaranteed, there may be unexpected behavior.
>
> What order??
I mean one stop operation is ongoing, one other process tries to call
a start operation.
>
>> For example, governor is in enable state, and one process
>> tries to stop the goveror, but it is scheduled out before policy->
>> governor->governor() is executed, but the governor enable flag is
>> set to false already. Then one other process tries to start governor,
>> It finds enable flag is false, and it can process down to do governor
>> start operation, So the governor is started twice.
>
> That's not possible. A process will not and should not call START
> before calling STOP. And so the order of calling these routines must
> be forced.
>
> Hence, we may not need your patch.
Please see below code in __cpufreq_governor function
mutex_lock(&cpufreq_governor_lock);
if ((!policy->governor_enabled && (event == CPUFREQ_GOV_STOP)) ||
//////////// <1> Here one process A tries
to stop governor, it finds governor is enabled, so it will pass down.
(policy->governor_enabled && (event == CPUFREQ_GOV_START))) {
/////////////<3> Process B tries to start
governor, it finds enable flag is false, so it can also pass down.
mutex_unlock(&cpufreq_governor_lock);
return -EBUSY;
}
if (event == CPUFREQ_GOV_STOP)
policy->governor_enabled = false;
//////////// < 2>
Here process A set flag to false and then process A is scheduled out
for some reasons(like interrupt or time slice end)
else if (event == CPUFREQ_GOV_START)
policy->governor_enabled = true;
mutex_unlock(&cpufreq_governor_lock);
ret = policy->governor->governor(policy, event);
///////////////<4> Process
B executes the governor start operation, process A is not scheduled
back yet. as policy->governor->governor is not protected by
the cpufreq_governor_lock, So this sequence can happen
really.
Thanks
Xiaoguang
next prev parent reply other threads:[~2013-08-14 7:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-13 7:09 Xiaoguang Chen
2013-08-13 7:09 ` [PATCH 2/2] cpufreq: Only do governor start after successful stop Xiaoguang Chen
2013-08-14 5:23 ` Viresh Kumar
2013-08-14 7:38 ` Xiaoguang Chen
2013-08-14 5:21 ` [PATCH 1/2] cpufreq: Add governor operation ongoing flag Viresh Kumar
2013-08-14 7:36 ` Xiaoguang Chen [this message]
2013-08-14 7:48 ` Viresh Kumar
2013-08-14 8:19 ` Xiaoguang Chen
2013-08-14 8:22 ` Viresh Kumar
2013-08-14 8:50 ` Xiaoguang Chen
2013-08-14 8:54 ` 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='CAFgnuDes_F7Q5CHbXKC=ndrn9Gr3PJfGj0QvDXA-FuGcq41CHQ@mail.gmail.com' \
--to=chenxg.marvell@gmail.com \
--cc=chenxg@marvell.com \
--cc=cpufreq@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=rjw@sisk.pl \
--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®