CPUFreq core fixes for v3.10-rc2
Viresh Kumar
maintainercover CPUFreq core fixes for v3.10-rc2
I just saw your pull request and so these should go in rc2 now.
These are fixes for cpufreq core and common governor part. They mostly impact systems which have set have_governor_per_policy to true. i.e. big LITTLE cpufreq driver.
Viresh Kumar (2):
cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers
cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping
policy refcount
drivers/cpufreq/cpufreq.c | 6 +++--- drivers/cpufreq/cpufreq_governor.c | 11 +++++++---- drivers/cpufreq/cpufreq_governor.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-)
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 1/2 cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers
There are two types of INIT/EXIT activities that we need to do for governors:
- Done only once per governor (doesn't depend how many instances of governor were there). eg: cpufreq_register_notifier() for conservative governor.
- Done per instance of governor, eg: sysfs_{create|remove}_group().
There were some corner cases where current code isn't able to handle them separately and so failing for some test cases.
We use two separate variables now for keeping track of above two requirements.
- governor->initialized for first one
- dbs_data->usage_count for per governor instance
--- drivers/cpufreq/cpufreq_governor.c | 11 +++++++---- drivers/cpufreq/cpufreq_governor.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-)
drivers/cpufreq/cpufreq_governor.c +7 -4
@@ -255,6 +255,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,if (have_governor_per_policy ()) {WARN_ON (dbs_data); }else if (dbs_data) { + dbs_data->usage_count++; policy->governor_data = dbs_data;return 0 ; }
@@ -266,6 +267,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy, } dbs_data->cdata = cdata; + dbs_data->usage_count =1 ; rc = cdata->init (dbs_data);if (rc) {pr_err ("%s: POLICY_INIT: init() failed\n" , __func__);
@@ -294,7 +296,8 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,set_sampling_rate (dbs_data,max (dbs_data->min_sampling_rate, latency *LATENCY_MULTIPLIER )); -if (dbs_data->cdata->governor ==GOV_CONSERVATIVE ) { +if ((cdata->governor ==GOV_CONSERVATIVE ) && + (!policy->governor->initialized)) {struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; cpufreq_register_notifier(cs_ops->notifier_block,
@@ -306,12 +309,12 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,return 0 ;case CPUFREQ_GOV_POLICY_EXIT : -if ((policy->governor->initialized ==1 ) || -have_governor_per_policy ()) { +if (!--dbs_data->usage_count) {sysfs_remove_group (get_governor_parent_kobj (policy),get_sysfs_attr (dbs_data)); -if (dbs_data->cdata->governor ==GOV_CONSERVATIVE ) { +if ((dbs_data->cdata->governor ==GOV_CONSERVATIVE ) && + (policy->governor->initialized ==1 )) {struct cs_ops *cs_ops = dbs_data->cdata->gov_ops; cpufreq_unregister_notifier(cs_ops->notifier_block,
drivers/cpufreq/cpufreq_governor.h +1 -0
@@ -211,6 +211,7 @@ struct common_dbs_data {struct dbs_data {struct common_dbs_data *cdata;unsigned int min_sampling_rate; +int usage_count;void *tuners;/* dbs_mutex protects dbs_enable in governor start/stop */
Signature · 1 line
1.7.12.rc2.18.g61b472e
Viresh Kumar
maintainerPATCH 2/2 cpufreq: Issue CPUFREQ_GOV_POLICY_EXIT notifier before dropping policy refcount
In reply to Viresh KumarWe must call __cpufreq_governor(data, CPUFREQ_GOV_POLICY_EXIT) before calling cpufreq_cpu_put(data), so that policy kobject have valid fields. Otherwise, removing last online cpu of policy->cpus causes this crash for ondemand/conservative governor.
[ 146.386064] [<c00fb076>] (sysfs_find_dirent+0xe/0xa8) from [<c00fb1bd>] (sysfs_get_dirent+0x21/0x58) [ 146.413440] [<c00fb1bd>] (sysfs_get_dirent+0x21/0x58) from [<c00fc259>] (sysfs_remove_group+0x85/0xbc) [ 146.441338] [<c00fc259>] (sysfs_remove_group+0x85/0xbc) from [<c02faad9>] (cpufreq_governor_dbs+0x369/0x4a0) [ 146.470795] [<c02faad9>] (cpufreq_governor_dbs+0x369/0x4a0) from [<c02f66d7>] (__cpufreq_governor+0x2b/0x8c) [ 146.500254] [<c02f66d7>] (__cpufreq_governor+0x2b/0x8c) from [<c02f6893>] (__cpufreq_remove_dev.isra.12+0x15b/0x250) [ 146.531799] [<c02f6893>] (__cpufreq_remove_dev.isra.12+0x15b/0x250) from [<c03e91c7>] (cpufreq_cpu_callback+0x2f/0x3c) [ 146.563860] [<c03e91c7>] (cpufreq_cpu_callback+0x2f/0x3c) from [<c0036fe1>] (notifier_call_chain+0x45/0x54) [ 146.593059] [<c0036fe1>] (notifier_call_chain+0x45/0x54) from [<c001e611>] (__cpu_notify+0x1d/0x34) [ 146.620177] [<c001e611>] (__cpu_notify+0x1d/0x34) from [<c03e5833>] (_cpu_down+0x63/0x1ac) [ 146.644948] [<c03e5833>] (_cpu_down+0x63/0x1ac) from [<c03e5997>] (cpu_down+0x1b/0x30) [ 146.668675] [<c03e5997>] (cpu_down+0x1b/0x30) from [<c03e60eb>] (store_online+0x27/0x54) [ 146.692922] [<c03e60eb>] (store_online+0x27/0x54) from [<c0295629>] (dev_attr_store+0x11/0x18) [ 146.718733] [<c0295629>] (dev_attr_store+0x11/0x18) from [<c00f9edd>] (sysfs_write_file+0xed/0x114) [ 146.745847] [<c00f9edd>] (sysfs_write_file+0xed/0x114) from [<c00b42a9>] (vfs_write+0x65/0xd8) [ 146.771656] [<c00b42a9>] (vfs_write+0x65/0xd8) from [<c00b4523>] (sys_write+0x2f/0x50) [ 146.795384] [<c00b4523>] (sys_write+0x2f/0x50) from [<c000cdc1>] (ret_fast_syscall+0x1/0x52)
Of course this only impacted drivers which have have_governor_per_policy set to true. i.e. big LITTLE cpufreq driver.
--- drivers/cpufreq/cpufreq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/cpufreq/cpufreq.c +3 -3
@@ -1075,14 +1075,14 @@ static int __cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif __func__, cpu_dev->id, cpu); } +if ((cpus ==1 ) && (cpufreq_driver->target)) +__cpufreq_governor (data,CPUFREQ_GOV_POLICY_EXIT ); +pr_debug ("%s: removing link, cpu: %d\n" , __func__, cpu);cpufreq_cpu_put (data);/* If cpu is last user of policy, free policy */ if (cpus ==1 ) { -if (cpufreq_driver->target) -__cpufreq_governor (data,CPUFREQ_GOV_POLICY_EXIT ); -lock_policy_rwsem_read (cpu); kobj = &data->kobj; cmp = &data->kobj_unregister;
Signature · 1 line
1.7.12.rc2.18.g61b472e
Quoted 11 lines · Viresh Kumar
I just saw your pull request and so these should go in rc2 now.
These are fixes for cpufreq core and common governor part. They mostly impact systems which have set
have_governor_per_policyto true. i.e. big LITTLE cpufreq driver.Viresh Kumar (2):
cpufreq: governors: Fix CPUFREQ_GOV_POLICY_{INIT|EXIT} notifiers
cpufreq: IssueCPUFREQ_GOV_POLICY_EXITnotifier before dropping
policy refcount
Quoted 4 lines
drivers/cpufreq/cpufreq.c | 6 +++--- drivers/cpufreq/cpufreq_governor.c | 11 +++++++---- drivers/cpufreq/cpufreq_governor.h | 1 + 3 files changed, 11 insertions(+), 7 deletions(-)
Both queued up for the v3.10-rc2 push.
Thanks,
Rafael
Signature · 2 lines
I speak only for myself. Rafael J. Wysocki, Intel Open Source Technology Center.