public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lan Tianyu <tianyu.lan@intel.com>
To: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: viresh.kumar@linaro.org, cpufreq@vger.kernel.org,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Date: Sat, 16 Nov 2013 11:59:59 +0800	[thread overview]
Message-ID: <5286EDBF.9050001@intel.com> (raw)
In-Reply-To: <2368963.sKiLjXYCVt@vostro.rjw.lan>

On 11/16/2013 08:38 AM, Rafael J. Wysocki wrote:
> On Friday, November 15, 2013 04:15:34 PM Lan Tianyu wrote:
>> Currently, governor of nonboot cpus will be put to EXIT when system suspend.
>> Since all these cpus will be unplugged and the governor usage_count decreases
>> to zero. The governor data and its sysfs interfaces will be freed or released.
>> This makes user config of these governors loss during suspend and resume.
>
> First off, do we have a pointer to a bug report related to that?
>

No, I found this bug when I tried to resolve other similar bug.
https://bugzilla.kernel.org/show_bug.cgi?id=63081. I still have no idea 
about bug 63081 and asked reporter to try this patch.

> Second, what does need to be done to reproduce this problem?
>

Defaultly, all cpus use ondemand governor after bootup. Change one 
non-boot cpu's governor to conservative, modify conservative config via 
sysfs interface and then do system suspend. After resume, the config
of conservative is reset. On my machine, all cpus have owen policy.


>> This doesn't happen on the governor covering boot cpu because it isn't
>> unplugged during system suspend.
>>
>> To fix this issue, skipping governor exit during system suspend and check
>> policy governor data to determine whether the governor is really needed
>> to be initialized when do init. If not, return EALREADY to indicate the
>> governor has been initialized and should do nothing. __cpufreq_governor()
>> convert EALREADY to 0 as return value for INIT event since governor is
>> still under INIT state and can do START operation.
>>
>> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
>> ---
>> Fix some typos
>>
>>   drivers/cpufreq/cpufreq.c          |  5 ++++-
>>   drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++-
>>   2 files changed, 16 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index 02d534d..38f2e4a 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -1239,7 +1239,7 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
>>
>>   	/* If cpu is last user of policy, free policy */
>>   	if (cpus == 1) {
>> -		if (has_target()) {
>> +		if (has_target() && !frozen) {
>>   			ret = __cpufreq_governor(policy,
>>   					CPUFREQ_GOV_POLICY_EXIT);
>>   			if (ret) {
>> @@ -1822,6 +1822,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,
>>   			((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))
>>   		module_put(policy->governor->owner);
>>
>> +	if ((event == CPUFREQ_GOV_POLICY_INIT) && ret == -EALREADY)
>> +		ret = 0;
>> +
>>   	return ret;
>>   }
>>
>> diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
>> index 0806c31..ddb93af 100644
>> --- a/drivers/cpufreq/cpufreq_governor.c
>> +++ b/drivers/cpufreq/cpufreq_governor.c
>> @@ -204,9 +204,20 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
>>
>>   	switch (event) {
>>   	case CPUFREQ_GOV_POLICY_INIT:
>> +		/*
>> +		 * In order to keep governor data across suspend/resume,
>> +		 * Governor doesn't exit when suspend and will be
>> +		 * reinitialized when resume. Here check policy governor
>> +		 * data to determine whether the governor has been exited.
>> +		 * If not, return EALREADY.
>> +		 */
>>   		if (have_governor_per_policy()) {
>> -			WARN_ON(dbs_data);
>> +			if (dbs_data)
>> +				return -EALREADY;
>>   		} else if (dbs_data) {
>> +			if (policy->governor_data == dbs_data)
>> +				return -EALREADY;
>> +
>>   			dbs_data->usage_count++;
>>   			policy->governor_data = dbs_data;
>>   			return 0;
>>


-- 
Best Regards
Tianyu Lan

  reply	other threads:[~2013-11-16  4:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-15  6:01 [PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system syspend/resume Lan Tianyu
2013-11-15  8:15 ` [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume Lan Tianyu
2013-11-15 10:22   ` Viresh Kumar
2013-11-16  4:33     ` Lan Tianyu
2013-11-15 10:54   ` Viresh Kumar
2013-11-16  5:24     ` viresh kumar
2013-11-16  0:38   ` Rafael J. Wysocki
2013-11-16  3:59     ` Lan Tianyu [this message]
2013-11-16 14:41       ` Rafael J. Wysocki
2013-11-16 14:57         ` Viresh Kumar
2013-11-16 15:10           ` Rafael J. Wysocki
2013-11-16 15:09         ` Rafael J. Wysocki
2013-11-16 15:23         ` Lan Tianyu
2013-11-16 15:36         ` [PATCH V2] " Lan Tianyu
2013-11-17  4:13           ` viresh kumar
2013-11-17 14:44             ` Rafael J. Wysocki
2013-11-17 16:23               ` Viresh Kumar
2013-11-22  7:49             ` viresh kumar
2013-11-22  8:19               ` Lan Tianyu
2013-11-22  8:39                 ` Viresh Kumar
2013-11-21 14:43           ` Rafael J. Wysocki
2013-11-21 15:54             ` Viresh Kumar
2013-11-21 21:43               ` Rafael J. Wysocki

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=5286EDBF.9050001@intel.com \
    --to=tianyu.lan@intel.com \
    --cc=cpufreq@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@rjwysocki.net \
    --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