Cpufreq: Make governor data on nonboot cpus across system syspend/resume
PATCH 1/1 Cpufreq: Make governor data on nonboot cpus across system syspend/resume
Currently, governor of nonboot cpus will be put to EXIT when system syspend. 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.
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.
--- drivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +4 -1
@@ -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; }
drivers/cpufreq/cpufreq_governor.c +12 -1
@@ -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 ;
Signature · 1 line
1.8.2.1
PATCH 1/1 Cpufreq: Make governor data on nonboot cpus across system suspend/resume
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.
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.
---
Fix some typos
drivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)
drivers/cpufreq/cpufreq.c +4 -1
@@ -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; }
drivers/cpufreq/cpufreq_governor.c +12 -1
@@ -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 ;
Signature · 1 line
1.8.2.1
Viresh Kumar
maintainerRe: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 15 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.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.
Quoted 2 lines
Signed-off-by Lan Tianyu <[email protected]>---
Hi Lan..
Apologies!!
I already had a solution for this as this was reported by few Broadcom people as well. But I haven't send it to mainline yet as it was untested. It looked similar
to what you had..
And so I would have taken your patch (as you have sent it first to the list and there is no real advantage of my patch over yours, they were almost same) :)
But then I went chasing another bug posted by Nishant:
https://lkml.org/lkml/2013/10/24/369
And the final solution I have to write solved all the problems you and he reported.
Please have a look at that patch (you are cc'd) and give it a try to see if it fixes your problem..
Btw, One question about your setup:
- you must have a multi cluster/socket SoC as you have atleast one more policy structure than used for group containing boot cpu..
- Are you using separate governor for both groups?
- Or are you using CPUFREQ_HAVE_GOVERNOR_PER_POLICY stuff
to use same governor with separate tunables for both groups?
Just wanted to know if somebody else is also using CPUFREQ_HAVE_GOVERNOR_PER_POLICY :)
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 16 lines · Viresh Kumar
Quoted 15 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.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.
Quoted 5 lines
Quoted 2 lines
Signed-off-by Lan Tianyu <[email protected]>---
Hi Lan..
Hi Viresh:
Quoted 12 lines
Apologies!!
I already had a solution for this as this was reported by few Broadcom people as well. But I haven't send it to mainline yet as it was untested. It looked similar
to what you had..And so I would have taken your patch (as you have sent it first to the list and there is no real advantage of my patch over yours, they were almost same) :)
But then I went chasing another bug posted by Nishant:
Quoted 7 lines
https://lkml.org/lkml/2013/10/24/369
And the final solution I have to write solved all the problems you and he reported.
Please have a look at that patch (you are cc'd) and give it a try to see if it fixes your problem..
Never mind. I think it should work and will try it.
Quoted 4 lines
Btw, One question about your setup:
- you must have a multi cluster/socket SoC as you have atleast one more policy structure than used for group containing boot cpu..
Actually, I test on a laptop and find this issue when reading code to fix other bug. :)
All cpus have their own policys.
Quoted 1 line
- Are you using separate governor for both groups?
Just to produce the bug, I set one non-boot cpu to conservative gov. All other remain default "ondemand".
Quoted 3 lines
- Or are you using
CPUFREQ_HAVE_GOVERNOR_PER_POLICYstuff to use same governor with separate tunables for both groups?
No, I am not using this.
Quoted 3 lines
Just wanted to know if somebody else is also using
CPUFREQ_HAVE_GOVERNOR_PER_POLICY:)
Signature · 2 lines
Best Regards Tianyu Lan
Viresh Kumar
maintainerRe: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Lan TianyuAdding Rainer as well
Quoted 8 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.This doesn't happen on the governor covering boot cpu because it isn't unplugged during system suspend.
Quoted 6 lines
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.
Though the patch I have sent fixes a problem similar to this but I don't think patch of any of us will solve the issue Rainer is facing..
I checked his system configuration and its like this:
- Four CPUs, all having separate clock domains (atleast from kernel perspective) and so separate policy structure.
- All are using ondemand governor
- not using CPUFREQ_HAVE_GOVERNOR_PER_POLICY feature
- So there is a single set of tunables for ondemand governor that is applicable across all CPUs..
The way INIT/EXIT are designed in cpufreq_governor.c should take care of this scenario.
memory for tunables must not be freed unless all the CPUs are removed. Which can't happen, as we only offline non-boot CPUs and so I believe that memory isn't getting freed and so your solution wouldn't address his problem..
Sorry if I said something stupid enough :)
--
viresh
viresh kumar
maintainerRe: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 14 lines · Viresh Kumar
Though the patch I have sent fixes a problem similar to this but I don't think patch of any of us will solve the issue Rainer is facing..
I checked his system configuration and its like this:
- Four CPUs, all having separate clock domains (atleast from kernel perspective) and so separate policy structure.
- All are using ondemand governor
- not usingCPUFREQ_HAVE_GOVERNOR_PER_POLICYfeature
- So there is a single set of tunables for ondemand governor that is applicable across all CPUs..The way INIT/EXIT are designed in
cpufreq_governor.cshould take care of this scenario.
Quoted 6 lines
memory for tunables must not be freed unless all the CPUs are removed. Which can't happen, as we only offline non-boot CPUs and so I believe that memory isn't getting freed and so your solution wouldn't address his problem..
Sorry if I said something stupid enough :)
I haven't :)
From your another mail it is clear that you have used separate governors and so you have faced the real problem :)
Hope my patch fixes it for you.
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Lan TianyuQuoted 4 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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?
Second, what does need to be done to reproduce this problem?
Quoted 68 lines
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 <[email protected]>---
Fix some typosdrivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)drivers/cpufreq/cpufreq.c +4
-1@@ -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; }drivers/cpufreq/cpufreq_governor.c +12
-1@@ -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 ;
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 8 lines · Rafael J. Wysocki
Quoted 4 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.
Quoted 2 lines
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.
Quoted 68 lines
Quoted 68 lines
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 <[email protected]>---
Fix some typosdrivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)drivers/cpufreq/cpufreq.c +4
-1@@ -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; }drivers/cpufreq/cpufreq_governor.c +12
-1@@ -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 ;
Signature · 2 lines
Best Regards Tianyu Lan
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 14 lines · Lan Tianyu
Quoted 8 lines · Rafael J. Wysocki
Quoted 4 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.
Quoted 5 lines
Quoted 2 lines
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,
Well, why would anyone want to do that? Just out of curiosity ...
Quoted 3 lines
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.
So this is acpi-cpufreq, right?
The patch looks basically OK to me, but ->
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
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 <[email protected]>---
Fix some typosdrivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)drivers/cpufreq/cpufreq.c +1
-1@@ -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);
Quoted 3 lines
Quoted 3 lines
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 3 lines
drivers/cpufreq/cpufreq.c +3
-0+if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret == -EALREADY ) + ret =0 ; +
-> I'd prefer this check to be combined with the one done to determine whether or not we need to do the module_put(). Something like
if (event == CPUFREQ_GOV_POLICY_EXIT && ret) {
module_put(policy->governor->owner);
if (ret == -EALREADY)
return 0;
} else if (event == CPUFREQ_GOV_POLICY_EXIT && !ret) {
module_put(policy->governor->owner);
}Thanks!
Quoted 33 lines
Quoted 30 lines
Quoted 30 lines
drivers/cpufreq/cpufreq.c +0
-0return ret; }drivers/cpufreq/cpufreq_governor.c +12
-1@@ -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 ;
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Viresh Kumar
maintainerRe: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Lan Tianyu
Defaultly, all cpus use ondemand governor after bootup. Change one non-boot cpu's governor to conservative,
Well, why would anyone want to do that? Just out of curiosity ...
People may want to use different group/cluster/socket of CPUs differently, with different kind of policies. Maybe performance governor for boot cpu and ondemand for others.
This bug would also be there for big LITTLE where we want to have separate set of tunables for big and LITTLE clusters for the same type of governor.
Quoted 1 line
So this is acpi-cpufreq, right?
Probably yes, I saw something similar somewhere.. But this is driver independent..
Quoted 1 line
The patch looks basically OK to me, but ->
We wouldn't need this patch if my other patch (where I am disabling governors in suspend/resume goes in, in any form)..
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 18 lines · Viresh Kumar
Quoted 6 lines · Rafael J. Wysocki
Quoted 2 lines · Lan Tianyu
Defaultly, all cpus use ondemand governor after bootup. Change one non-boot cpu's governor to conservative,
Well, why would anyone want to do that? Just out of curiosity ...
People may want to use different group/cluster/socket of CPUs differently, with different kind of policies. Maybe performance governor for boot cpu and ondemand for others.
This bug would also be there for big LITTLE where we want to have separate set of tunables for big and LITTLE clusters for the same type of governor.
Quoted 1 line
So this is acpi-cpufreq, right?
Quoted 7 lines
Probably yes, I saw something similar somewhere.. But this is driver independent..
Quoted 1 line
The patch looks basically OK to me, but ->
We wouldn't need this patch if my other patch (where I am disabling governors in suspend/resume goes in, in any form)..
Yes, I know that, but I don't think this is the right approach.
Thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Rafael J. WysockiOn Saturday, November 16, 2013 03:41:10 PM Rafael J. Wysocki wrote:
[...]
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/cpufreq/cpufreq.c +0
-0@@ -1822,6 +1822,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret))module_put (policy->governor->owner);
Quoted 8 lines
Quoted 3 lines
Quoted 3 lines
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 3 lines
drivers/cpufreq/cpufreq.c +3
-0+if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret == -EALREADY ) + ret =0 ; +-> I'd prefer this check to be combined with the one done to determine whether or not we need to do the
module_put(). Something likeif (event == CPUFREQ_GOV_POLICY_EXIT && ret) {
Obviously, that should be:
if (event == CPUFREQ_GOV_POLICY_INIT && ret) {Quoted 6 lines
module_put(policy->governor->owner);
if (ret == -EALREADY)
return 0;
} else if (event == CPUFREQ_GOV_POLICY_EXIT && !ret) {
module_put(policy->governor->owner);
}Sorry for the confusion.
Thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Re: [Update PATCH 1/1] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Rafael J. WysockiQuoted 15 lines · Rafael J. Wysocki
Quoted 14 lines · Lan Tianyu
Quoted 8 lines · Rafael J. Wysocki
Quoted 4 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
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,
Well, why would anyone want to do that? Just out of curiosity ...
Just use this way to produce the issue. But on the laptop, I think fewer people will do the same thing. Just like Viresh said, this also will affect the systems of governor per policy.
Quoted 7 lines
Quoted 4 lines
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.
So this is acpi-cpufreq, right?
Yes, it's acpi-cpufreq driver.
Quoted 44 lines
The patch looks basically OK to me, but ->
Quoted 35 lines
Quoted 35 lines
Quoted 35 lines
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 <[email protected]>---
Fix some typosdrivers/cpufreq/cpufreq.c | 5 ++++- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-)drivers/cpufreq/cpufreq.c +1
-1@@ -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);Quoted 3 lines
Quoted 3 lines
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 3 lines
drivers/cpufreq/cpufreq.c +3
-0+if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret == -EALREADY ) + ret =0 ; +-> I'd prefer this check to be combined with the one done to determine whether or not we need to do the
module_put(). Something like
Quoted 8 lines
if (event == CPUFREQ_GOV_POLICY_EXIT && ret) {
module_put(policy->governor->owner);
if (ret == -EALREADY)
return 0;
} else if (event == CPUFREQ_GOV_POLICY_EXIT && !ret) {
module_put(policy->governor->owner);
}Ok. I will update soon.
Quoted 35 lines
Thanks!
Quoted 33 lines
Quoted 30 lines
Quoted 30 lines
drivers/cpufreq/cpufreq.c +0
-0return ret; }drivers/cpufreq/cpufreq_governor.c +12
-1@@ -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 ;
Signature · 2 lines
Best Regards Tianyu Lan
PATCH v2 1/1 Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Rafael J. WysockiCurrently, 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.
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.
---
Change since v1:
Change coding style.
drivers/cpufreq/cpufreq.c | 10 +++++++--- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-)
drivers/cpufreq/cpufreq.c +7 -3
@@ -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) {
@@ -1818,9 +1818,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,mutex_unlock (&cpufreq_governor_lock); } -if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) { +module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {module_put (policy->governor->owner); + }return ret; }
drivers/cpufreq/cpufreq_governor.c +12 -1
@@ -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 ;
Signature · 1 line
1.8.2.1
viresh kumar
maintainerRe: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 4 lines · Lan Tianyu
drivers/cpufreq/cpufreq.c +0
-0@@ -1818,9 +1818,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,mutex_unlock (&cpufreq_governor_lock); }
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 10 lines
drivers/cpufreq/cpufreq.c +6
-2-if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) { +module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {module_put (policy->governor->owner); + }
This can still be written more efficiently I believe:
drivers/cpufreq/cpufreq.c +9 -6
@@ -1866,10 +1866,12 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, ret = policy->governor->governor (policy, event);if (!ret) { -if (event ==CPUFREQ_GOV_POLICY_INIT ) +if (event ==CPUFREQ_GOV_POLICY_INIT ) { policy->governor->initialized++; -else if (event ==CPUFREQ_GOV_POLICY_EXIT ) + }else if (event ==CPUFREQ_GOV_POLICY_EXIT ) { policy->governor->initialized--; +module_put (policy->governor->owner); + } }else {/* Restore original values */ mutex_lock (&cpufreq_governor_lock);
@@ -1877,13 +1879,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, policy->governor_enabled = true; else if (event == CPUFREQ_GOV_START) policy->governor_enabled = false; + else if (event == CPUFREQ_GOV_POLICY_INIT) + if (ret == -EALREADY) { +module_put (policy->governor->owner); + ret =0 ; + }mutex_unlock (&cpufreq_governor_lock); } -if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) -module_put (policy->governor->owner); -return ret;
Quoted 18 lines
drivers/cpufreq/cpufreq.c +0
-0return ret; }drivers/cpufreq/cpufreq_governor.c +7
-0@@ -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 ()) {
drivers/cpufreq/cpufreq_governor.c int cpufreq_governor_dbs(struct cpufreq_policy *policy, · line 223
Quoted 10 lines
drivers/cpufreq/cpufreq_governor.c +5
-1-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 ;
But I don't really like the solution here. You are handling frozen for EXIT in cpufreq-core and for INIT in governor. That doesn't look like the right approach. There are out of tree governors too (I know we don't care about them :)), and those also need to adapt with some policy made at cpufreq-core level.
I told you that I had another solution for this problem, pretty similar to yours. It looked like this:
drivers/cpufreq/cpufreq.c +3 -2
@@ -408,7 +408,8 @@ show_one(scaling_max_freq, max);show_one (scaling_cur_freq, cur);static int cpufreq_set_policy (struct cpufreq_policy *policy, -struct cpufreq_policy *new_policy); +struct cpufreq_policy *new_policy, +bool frozen);/** * cpufreq_per_cpu_attr_write() / store_##file_name() - sysfs write access
@@ -428,7 +429,7 @@ static ssize_t store_##file_name \if (ret !=1 ) \return -EINVAL ; \ \ - ret =cpufreq_set_policy (policy, &new_policy); \ + ret =cpufreq_set_policy (policy, &new_policy, false); \ policy->user_policy.object = policy->object; \ \return ret ? ret : count; \
@@ -486,7 +487,7 @@ static ssize_t store_scaling_governor(struct cpufreq_policy
*policy,
&new_policy.governor))
return -EINVAL;
- ret = cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy, false);
policy->user_policy.policy = policy->policy; policy->user_policy.governor = policy->governor;
@@ -822,7 +823,7 @@ err_out_kobj_put:
return ret;
}
-static void cpufreq_init_policy(struct cpufreq_policy *policy) +static void cpufreq_init_policy(struct cpufreq_policy *policy, bool frozen)
{
struct cpufreq_policy new_policy;
int ret = 0;
@@ -832,7 +833,7 @@ static void cpufreq_init_policy(struct cpufreq_policy *policy)
policy->governor = NULL;
/* set default policy */
- ret = cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy, frozen);
policy->user_policy.policy = policy->policy; policy->user_policy.governor = policy->governor;
@@ -1077,7 +1078,7 @@ static int __cpufreq_add_dev(struct device *dev, struct subsys_interface *sif,
list_add(&policy->policy_list, &cpufreq_policy_list); write_unlock_irqrestore(&cpufreq_driver_lock, flags);
- cpufreq_init_policy(policy);
+ cpufreq_init_policy(policy, frozen);
kobject_uevent(&policy->kobj, KOBJ_ADD); up_read(&cpufreq_rwsem);
@@ -1239,17 +1240,17 @@ static int __cpufreq_remove_dev_finish(struct device *dev,
/* If cpu is last user of policy, free policy */ if (cpus == 1) {
- if (has_target()) {
- ret = __cpufreq_governor(policy,
- CPUFREQ_GOV_POLICY_EXIT);
- if (ret) {
- pr_err("%s: Failed to exit governor\n",
- __func__);
- return ret;
+ if (!frozen) {
+ if (has_target()) {
+ ret = __cpufreq_governor(policy,
+ CPUFREQ_GOV_POLICY_EXIT);
+ if (ret) {
+ pr_err("%s: Failed to exit governor\n",
+ __func__);
+ return ret;
+ }
}
- }
- if (!frozen) {
down_read(&policy->rwsem); kobj = &policy->kobj;
cmp = &policy->kobj_unregister;
@@ -1920,7 +1921,7 @@ EXPORT_SYMBOL(cpufreq_get_policy);
* new_policy: policy to be set.
*/
static int cpufreq_set_policy(struct cpufreq_policy *policy,
- struct cpufreq_policy *new_policy)
+ struct cpufreq_policy *new_policy, bool frozen)
{
int ret = 0, failed = 1;
@@ -1987,7 +1988,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *policy,
/* start new governor */
policy->governor = new_policy->governor;
- if (!__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) {
+ if (frozen || !__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_INIT)) {
if (!__cpufreq_governor(policy, CPUFREQ_GOV_START)) {
failed = 0;
} else {
@@ -2065,7 +2066,7 @@ int cpufreq_update_policy(unsigned int cpu)
}
}
- ret = cpufreq_set_policy(policy, &new_policy);
+ ret = cpufreq_set_policy(policy, &new_policy, false);
up_write(&policy->rwsem);
-------------------------------
But after the PM notifiers patch I even don't want this to go.. I will make sure that that patch goes in, in one form or another :)
So, just wait for sometime before posting a new version :) (I know you did it because Rafael suggested a change)..
Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 38 lines · viresh kumar
Quoted 4 lines · Lan Tianyu
drivers/cpufreq/cpufreq.c +0
-0@@ -1818,9 +1818,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,mutex_unlock (&cpufreq_governor_lock); }drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 10 lines
drivers/cpufreq/cpufreq.c +6
-2-if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) { +module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {module_put (policy->governor->owner); + }This can still be written more efficiently I believe:
drivers/cpufreq/cpufreq.c +4
-2@@ -1866,10 +1866,12 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, ret = policy->governor->governor (policy, event);if (!ret) { -if (event ==CPUFREQ_GOV_POLICY_INIT ) +if (event ==CPUFREQ_GOV_POLICY_INIT ) { policy->governor->initialized++; -else if (event ==CPUFREQ_GOV_POLICY_EXIT ) + }else if (event ==CPUFREQ_GOV_POLICY_EXIT ) { policy->governor->initialized--; +module_put (policy->governor->owner); + } }else {/* Restore original values */ mutex_lock (&cpufreq_governor_lock);
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1883
Quoted 5 lines
drivers/cpufreq/cpufreq.c +2
-0@@ -1877,13 +1879,14 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, policy->governor_enabled = true; else if (event == CPUFREQ_GOV_START) policy->governor_enabled = false; + else if (event == CPUFREQ_GOV_POLICY_INIT) + if (ret == -EALREADY) {
You can write this as
else if (event == CPUFREQ_GOV_POLICY_INIT && ret == -EALREADY) {drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1890
Quoted 11 lines
drivers/cpufreq/cpufreq.c +3
-4+module_put (policy->governor->owner); + ret =0 ; + }mutex_unlock (&cpufreq_governor_lock); } -if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) -module_put (policy->governor->owner); -return ret;
Apart from the above I agree.
Thanks!
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.
Viresh Kumar
maintainerRe: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 8 lines · Rafael J. Wysocki
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1883
Quoted 2 lines · viresh kumar
drivers/cpufreq/cpufreq.c +2
-0+else if (event ==CPUFREQ_GOV_POLICY_INIT ) +if (ret == -EALREADY ) {You can write this as
else if (event == CPUFREQ_GOV_POLICY_INIT && ret == -EALREADY) {
I wrote it that way on the first go (though with separate braces for both comparisons
as well), but there were multiple statements to enclose and so will require {} and then
that would have to be added for above single line if/else as well, if we follow coding
guidelines properly..
Anyway, this code is no more required. :)
Quoted 6 lines
Quoted 6 lines
drivers/cpufreq/cpufreq.c +3
-0+module_put (policy->governor->owner); + ret =0 ; + }mutex_unlock (&cpufreq_governor_lock); }
Quoted 7 lines
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1890
Quoted 5 lines
drivers/cpufreq/cpufreq.c +0
-4-if (((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) || - ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret)) -module_put (policy->governor->owner); -return ret;Apart from the above I agree.
Thanks..
viresh kumar
maintainerRe: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to viresh kumarQuoted 9 lines · viresh kumar
On 16 November 2013 21:06, Lan Tianyu <[email protected]> wrote:
But I don't really like the solution here. You are handling frozen for EXIT in cpufreq-core and for INIT in governor. That doesn't look like the right approach. There are out of tree governors too (I know we don't care about them :)), and those also need to adapt with some policy made at cpufreq-core level.
I told you that I had another solution for this problem, pretty similar to yours. It looked like this:
Hi Lan,
There is some confusion going on here :)
There were few problems in the approach in your patch, which I have mentioned above, and Rafael agreed to them..
Quoted 2 lines
But after the PM notifiers patch I even don't want this to go.. I will make sure that that patch goes in, in one form or another :)
And I was still trying to get a better solution in place of these changes. And was going on the suggestions you gave about calling cpufreq callbacks from dpm_{suspend|resume}_noirq() calls.. And I am on my way to get things fixed that way. And so we don't actually need this patch anymore (I just saw that you have sent another version of it, probably because Rafael asked? Don't know what happened there :))..
So, I will try to get something working soon for you and Nishanth..
Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 8 lines · viresh kumar
Quoted 7 lines · viresh kumar
On 16 November 2013 21:06, Lan Tianyu <[email protected]> wrote:
But I don't really like the solution here. You are handling frozen for EXIT in cpufreq-core and for INIT in governor. That doesn't look like the right approach. There are out of tree governors too (I know we don't care about them :)), and those also need to adapt with some policy made at cpufreq-core level.
Quoted 5 lines
Quoted 2 lines
I told you that I had another solution for this problem, pretty similar to yours. It looked like this:
Hi Lan,
Hi Viresh:
Quoted 2 lines
There is some confusion going on here :)
I think you also are in the Cc list and replied the mail.:)
https://lkml.org/lkml/2013/11/21/273
Quoted 2 lines
There were few problems in the approach in your patch, which I have mentioned above, and Rafael agreed to them..
I only saw the out-of-tree governor issue your mentioned but where they are? How upstream kernel cares them?
Quoted 13 lines
Quoted 3 lines
But after the PM notifiers patch I even don't want this to go.. I will make sure that that patch goes in, in one form or another :)
And I was still trying to get a better solution in place of these changes. And was going on the suggestions you gave about calling cpufreq callbacks from dpm_{suspend|resume}_noirq() calls.. And I am on my way to get things fixed that way. And so we don't actually need this patch anymore (I just saw that you have sent another version of it, probably because Rafael asked? Don't know what happened there :))..
So, I will try to get something working soon for you and Nishanth..
Signature · 2 lines
Best regards Tianyu Lan
Viresh Kumar
maintainerRe: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 2 lines · Lan Tianyu
I think you also are in the Cc list and replied the mail.:)
https://lkml.org/lkml/2013/11/21/273
Yeah, my reply was more about the coding style and I should have asked again on the same mail about waiting for sometime before posting V3... My fault!!
Quoted 2 lines
I only saw the out-of-tree governor issue your mentioned but where they are? How upstream kernel cares them?
That's what I said, we might not care about them. But I had issues with the design of your patch:
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
But I don't really like the solution here. You are handling frozen for EXIT in cpufreq-core and for INIT in governor. That doesn't look like the right approach.
And so gave the solution I had as well.. And then said, I even don't want my solution to go in, as this can be fixed by taking adequate steps before removing non-boot CPUs and we are still in discussions for that.
I will post the short term solution that Rafael referred to as soon as possible and will discuss more with Rafael about the long term one (As Rafael pointed out).
Sorry for the confusion..
Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
In reply to Lan TianyuQuoted 38 lines · Lan Tianyu
Currently, governor of nonboot cpus will be put to EXIT when system suspend. Since all these cpus will be unplugged and the governor
usage_countdecreases 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.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 <[email protected]>---
Change since v1:
Change coding style.drivers/cpufreq/cpufreq.c | 10 +++++++--- drivers/cpufreq/cpufreq_governor.c | 13 ++++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-)drivers/cpufreq/cpufreq.c +1
-1@@ -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) {
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1821
Quoted 4 lines
drivers/cpufreq/cpufreq.c +0
-1@@ -1818,9 +1818,13 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,mutex_unlock (&cpufreq_governor_lock); } - if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
The inner parens are not necessary.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1821
Quoted 2 lines
drivers/cpufreq/cpufreq.c +1
-1- ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) {
Same here.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1825
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {
Same here.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1827
Quoted 2 lines
drivers/cpufreq/cpufreq.c +1
-0module_put (policy->governor->owner); + }
Can you please combine these checks with the checks made right after calling policy->governor->governor() as indicated by Viresh?
Rafael
Viresh Kumar
maintainerRe: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 7 lines · Rafael J. Wysocki
Quoted 1 line
- if (((event ==
CPUFREQ_GOV_POLICY_INIT) && ret) ||The inner parens are not necessary.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1821
Quoted 2 lines
drivers/cpufreq/cpufreq.c +1
-1- ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) {
Quoted 8 lines
Same here.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1825
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {Same here.
Logically, yes you are correct. But probably its better for readability to get these even if you know precedence is going to take care of our expression..
Re: [PATCH V2] Cpufreq: Make governor data on nonboot cpus across system suspend/resume
Quoted 15 lines · Viresh Kumar
Quoted 14 lines · Rafael J. Wysocki
Quoted 1 line
- if (((event ==
CPUFREQ_GOV_POLICY_INIT) && ret) ||The inner parens are not necessary.
drivers/cpufreq/cpufreq.c static int __cpufreq_governor(struct cpufreq_policy *policy, · line 1821
Quoted 2 lines
drivers/cpufreq/cpufreq.c +1
-1- ((event == CPUFREQ_GOV_POLICY_EXIT) && !ret)) +if ((event ==CPUFREQ_GOV_POLICY_INIT ) && ret) {Same here.
Quoted 4 lines
drivers/cpufreq/cpufreq.c +4
-0+module_put (policy->governor->owner); +if (ret == -EALREADY ) +return 0 ; + }else if ((event ==CPUFREQ_GOV_POLICY_EXIT ) && !ret) {
Quoted 5 lines
Quoted 1 line
Same here.
Logically, yes you are correct. But probably its better for readability to get these even if you know precedence is going to take care of our expression..
Are you serious?
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.