cpufreq: Locking fixes and cleanups
Viresh Kumar
maintainerv4 cover cpufreq: Locking fixes and cleanups
Hi Rafael,
These are rest of the patches that fix some more locking issues with policy->rwsem and do some minor optimization/cleanups.
These were part of the 13 patch series which was sent earlier. The last patch is new, and does what I suggested to one of your commits.
V3->V4:
- Reordered all the patches and created a new series.
- s/global/common for common tunables
- One new patch
@Juri/Shilpa: I have added your Tested-by for the first 6 patches, please let me know if you don't want to add that.
Viresh Kumar (7):
cpufreq: Merge cpufreq_offline_prepare/finish routines
cpufreq: Call __cpufreq_governor() with policy->rwsem held
cpufreq: Remove cpufreq_governor_lock
cpufreq: governor: Move common sysfs tunables to cpufreq_governor.c
cpufreq: governor: No need to manage state machine now
cpufreq: conservative: Update sample_delay_ns immediately
cpufreq: ondemand: Rearrange od_dbs_timer() to void updating delay
drivers/cpufreq/cpufreq.c | 93 +++++++++--------- drivers/cpufreq/cpufreq_conservative.c | 80 +++------------- drivers/cpufreq/cpufreq_governor.c | 170 ++++++++++++++++++++++++++++----- drivers/cpufreq/cpufreq_governor.h | 16 +++- drivers/cpufreq/cpufreq_ondemand.c | 153 +++++------------------------ 5 files changed, 240 insertions(+), 272 deletions(-)
Signature · 1 line
2.7.1.370.gb2aa7f8
Viresh Kumar
maintainerPATCH v4 1/7 cpufreq: Merge cpufreq_offline_prepare/finish routines
The offline routine was separated into two halves earlier by 'commit 1aee40ac9c86 ("cpufreq: Invoke __cpufreq_remove_dev_finish() after releasing cpu_hotplug.lock");.
And the reasons cited were, race issues between accessing policy's sysfs files and policy kobject's cleanup.
That race isn't valid anymore, as we don't remove the policy & its kobject completely on hotplugs, but do that from ->remove() callback of subsys framework.
These two routines can be merged back now.
This is a preparatory step for the next patch, that will enforce policy->rwsem lock around __cpufreq_governor() routines STOP/EXIT sequence.
--- drivers/cpufreq/cpufreq.c | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-)
drivers/cpufreq/cpufreq.c +10 -26
@@ -1361,9 +1361,10 @@ static int cpufreq_add_dev(struct device *dev, struct subsys_interface *sif)return ret; } -static void cpufreq_offline_prepare (unsigned int cpu) +static void cpufreq_offline (unsigned int cpu) {struct cpufreq_policy *policy; +int ret;pr_debug ("%s: unregistering CPU %u\n" , __func__, cpu);
@@ -1374,7 +1375,7 @@ static void cpufreq_offline_prepare(unsigned int cpu) }if (has_target ()) { -int ret =__cpufreq_governor (policy,CPUFREQ_GOV_STOP ); + ret =__cpufreq_governor (policy,CPUFREQ_GOV_STOP );if (ret)pr_err ("%s: Failed to stop governor\n" , __func__); }
@@ -1397,34 +1398,23 @@ static void cpufreq_offline_prepare(unsigned int cpu)/* Start governor again for active policy */ if (!policy_is_inactive (policy)) {if (has_target ()) { -int ret =__cpufreq_governor (policy,CPUFREQ_GOV_START ); + ret =__cpufreq_governor (policy,CPUFREQ_GOV_START );if (!ret) ret =__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS );if (ret)pr_err ("%s: Failed to start governor\n" , __func__); } - }else if (cpufreq_driver->stop_cpu) { - cpufreq_driver->stop_cpu (policy); - } -} -static void cpufreq_offline_finish (unsigned int cpu) -{ -struct cpufreq_policy *policy =per_cpu (cpufreq_cpu_data, cpu); - -if (!policy) { -pr_debug ("%s: No cpu_data found\n" , __func__);return ; } -/* Only proceed for inactive policies */ -if (!policy_is_inactive (policy)) -return ; +if (cpufreq_driver->stop_cpu) + cpufreq_driver->stop_cpu (policy);/* If cpu is last user of policy, free policy */ if (has_target ()) { -int ret =__cpufreq_governor (policy,CPUFREQ_GOV_POLICY_EXIT ); + ret =__cpufreq_governor (policy,CPUFREQ_GOV_POLICY_EXIT );if (ret)pr_err ("%s: Failed to exit governor\n" , __func__); }
@@ -1453,10 +1443,8 @@ static void cpufreq_remove_dev(struct device *dev, struct subsys_interface *sif)if (!policy)return ; -if (cpu_online (cpu)) { -cpufreq_offline_prepare (cpu); -cpufreq_offline_finish (cpu); - } +if (cpu_online (cpu)) +cpufreq_offline (cpu);cpumask_clear_cpu (cpu, policy->real_cpus);remove_cpu_dev_symlink (policy, cpu);
@@ -2304,11 +2292,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,break ;case CPU_DOWN_PREPARE : -cpufreq_offline_prepare (cpu); -break ; - -case CPU_POST_DEAD : -cpufreq_offline_finish (cpu); +cpufreq_offline (cpu);break ;case CPU_DOWN_FAILED :
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 1/7] cpufreq: Merge cpufreq_offline_prepare/finish routines
Quoted 10 lines · Viresh Kumar
The offline routine was separated into two halves earlier by 'commit
1aee40ac9c86("cpufreq: Invoke__cpufreq_remove_dev_finish()after releasing cpu_hotplug.lock");.And the reasons cited were, race issues between accessing policy's sysfs files and policy kobject's cleanup.
That race isn't valid anymore, as we don't remove the policy & its kobject completely on hotplugs, but do that from ->remove() callback of subsys framework.
Governor sysfs attributes are still removed in __cpufreq_governor(_EXIT), though, so had store() been used for them, the deadlock described in the changelog of commit 1aee40ac9c86 would have been possible.
Fortunately, we don't use store() (which still does get_online_cpus()) for those attributes now. We use governor_store() for them and that doesn't call get_online_cpus(). So in fact this patch is only correct after the recent rework of the governor attributes handling.
Please modify the changelog to explain that more thoroughly.
Thanks,
Rafael
Rafael J. Wysocki
maintainerRe: [PATCH V4 1/7] cpufreq: Merge cpufreq_offline_prepare/finish routines
Quoted 17 lines · Rafael J. Wysocki
Quoted 10 lines · Viresh Kumar
The offline routine was separated into two halves earlier by 'commit
1aee40ac9c86("cpufreq: Invoke__cpufreq_remove_dev_finish()after releasing cpu_hotplug.lock");.And the reasons cited were, race issues between accessing policy's sysfs files and policy kobject's cleanup.
That race isn't valid anymore, as we don't remove the policy & its kobject completely on hotplugs, but do that from ->remove() callback of subsys framework.
Governor sysfs attributes are still removed in
__cpufreq_governor(_EXIT), though, so hadstore()been used for them, the deadlock described in the changelog of commit1aee40ac9c86would have been possible.
Quoted 6 lines
Fortunately, we don't use
store()(which still doesget_online_cpus()) for those attributes now. We usegovernor_store()for them and that doesn't callget_online_cpus(). So in fact this patch is only correct after the recent rework of the governor attributes handling.Please modify the changelog to explain that more thoroughly.
And one question tangentially related to this patch: Would it be possible to avoid calling __cpufreq_governor(_EXIT) for CPU offline?
The fact that we still carry out the whole governor teardown at that point is slightly disturbing, as in theory it should be possible to keep the governor attributes in place across offline/online.
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH V4 1/7] cpufreq: Merge cpufreq_offline_prepare/finish routines
Quoted 6 lines · Rafael J. Wysocki
And one question tangentially related to this patch: Would it be possible to avoid calling
__cpufreq_governor(_EXIT)for CPU offline?The fact that we still carry out the whole governor teardown at that point is slightly disturbing, as in theory it should be possible to keep the governor attributes in place across offline/online.
Will think about that after the current code is stable a bit. It should be possible, but need to see if it is worth it.
Signature · 1 line
viresh
Viresh Kumar
maintainerPATCH v4 2/7 cpufreq: Call __cpufreq_governor() with policy->rwsem held
In reply to Viresh KumarThis isn't followed properly by all parts of the core code, some follow it, whereas others don't.
Enforcing it will also enable us to remove cpufreq_governor_lock, that is used today because we can't guarantee that __cpufreq_governor() isn't executed in parallel.
We should also ensure that the lock is held across state changes to the governors.
For example, while adding a CPU to the policy on cpu-online path, we need to stop the governor, change policy->cpus, start the governor and then refresh its limits. The complete sequence must be guaranteed to execute without any concurrent races. And that can be achieved using policy->rwsem around these use cases.
Also note that cpufreq_driver->stop_cpu() and ->exit() can get called while policy->rwsem is held. That shouldn't have any side effects though.
--- drivers/cpufreq/cpufreq.c | 49 +++++++++++++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 16 deletions(-)
drivers/cpufreq/cpufreq.c +33 -16
@@ -1048,30 +1048,29 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cpif (cpumask_test_cpu (cpu, policy->cpus))return 0 ; +down_write (&policy->rwsem);if (has_target ()) { ret =__cpufreq_governor (policy,CPUFREQ_GOV_STOP );if (ret) {pr_err ("%s: Failed to stop governor\n" , __func__); -return ret; + goto unlock; } } -down_write (&policy->rwsem);cpumask_set_cpu (cpu, policy->cpus); -up_write (&policy->rwsem);if (has_target ()) { ret =__cpufreq_governor (policy,CPUFREQ_GOV_START );if (!ret) ret =__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); -if (ret) { +if (ret)pr_err ("%s: Failed to start governor\n" , __func__); -return ret; - } } -return 0 ; +unlock: +up_write (&policy->rwsem); +return ret; }static struct cpufreq_policy *cpufreq_policy_alloc (unsigned int cpu)
@@ -1374,13 +1373,13 @@ static void cpufreq_offline(unsigned int cpu)return ; } +down_write (&policy->rwsem);if (has_target ()) { ret =__cpufreq_governor (policy,CPUFREQ_GOV_STOP );if (ret)pr_err ("%s: Failed to stop governor\n" , __func__); } -down_write (&policy->rwsem);cpumask_clear_cpu (cpu, policy->cpus);if (policy_is_inactive (policy)) {
@@ -1393,7 +1392,6 @@ static void cpufreq_offline(unsigned int cpu)/* Nominate new CPU */ policy->cpu =cpumask_any (policy->cpus); } -up_write (&policy->rwsem);/* Start governor again for active policy */ if (!policy_is_inactive (policy)) {
@@ -1406,7 +1404,7 @@ static void cpufreq_offline(unsigned int cpu)pr_err ("%s: Failed to start governor\n" , __func__); } -return ; + goto unlock; }if (cpufreq_driver->stop_cpu)
@@ -1428,6 +1426,9 @@ static void cpufreq_offline(unsigned int cpu) cpufreq_driver->exit (policy); policy->freq_table =NULL ; } + +unlock: +up_write (&policy->rwsem); }/**
@@ -1624,6 +1625,7 @@ EXPORT_SYMBOL(cpufreq_generic_suspend);void cpufreq_suspend (void ) {struct cpufreq_policy *policy; +int ret;if (!cpufreq_driver)return ;
@@ -1634,7 +1636,11 @@ void cpufreq_suspend(void)pr_debug ("%s: Suspending Governors\n" , __func__);for_each_active_policy (policy) { -if (__cpufreq_governor (policy,CPUFREQ_GOV_STOP )) +down_write (&policy->rwsem); + ret =__cpufreq_governor (policy,CPUFREQ_GOV_STOP ); +up_write (&policy->rwsem); + +if (ret)pr_err ("%s: Failed to stop governor for policy: %p\n" , __func__, policy); else if (cpufreq_driver->suspend
@@ -1656,6 +1662,7 @@ void cpufreq_suspend(void)void cpufreq_resume (void ) {struct cpufreq_policy *policy; +int ret;if (!cpufreq_driver)return ;
@@ -1668,13 +1675,20 @@ void cpufreq_resume(void)pr_debug ("%s: Resuming Governors\n" , __func__);for_each_active_policy (policy) { -if (cpufreq_driver->resume && cpufreq_driver->resume (policy)) +if (cpufreq_driver->resume && cpufreq_driver->resume (policy)) {pr_err ("%s: Failed to resume driver: %p\n" , __func__, policy); -else if (__cpufreq_governor (policy,CPUFREQ_GOV_START ) - ||__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS )) -pr_err ("%s: Failed to start governor for policy: %p\n" , - __func__, policy); + }else { +down_write (&policy->rwsem); + ret =__cpufreq_governor (policy,CPUFREQ_GOV_START ); +if (!ret) +__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); +up_write (&policy->rwsem); + +if (ret) +pr_err ("%s: Failed to start governor for policy: %p\n" , + __func__, policy); + } }/*
@@ -2325,8 +2339,11 @@ static int cpufreq_boost_set_sw(int state) __func__);break ; } + +down_write (&policy->rwsem); policy->user_policy.max = policy->max;__cpufreq_governor (policy,CPUFREQ_GOV_LIMITS ); +up_write (&policy->rwsem); } }
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 2/7] cpufreq: Call __cpufreq_governor() with policy->rwsem held
Quoted 2 lines · Viresh Kumar
This isn't followed properly by all parts of the core code, some follow it, whereas others don't.
"The cpufreq core code is not consistent with respect to invoking __cpufreq_governor() under policy->rwsem."
Quoted 3 lines
Enforcing it will also enable us to remove
cpufreq_governor_lock, that is used today because we can't guarantee that__cpufreq_governor()isn't executed in parallel.
"Changing all code to always hold policy->rwsem around __cpufreq_governor() invocations will allow us to ..."
Quoted 9 lines
We should also ensure that the lock is held across state changes to the governors.
For example, while adding a CPU to the policy on cpu-online path, we need to stop the governor, change
policy->cpus, start the governor and then refresh its limits. The complete sequence must be guaranteed to execute without any concurrent races. And that can be achieved usingpolicy->rwsemaround these use cases.
Quoted 3 lines
Also note that
cpufreq_driver->stop_cpu()and ->exit() can get called whilepolicy->rwsemis held. That shouldn't have any side effects though.
The last paragraph is unclear.
Is it supposed to mean that the change will cause cpufreq_driver->stop_cpu() and ->exit() to be called under policy->rwsem sometimes?
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH V4 2/7] cpufreq: Call __cpufreq_governor() with policy->rwsem held
Quoted 10 lines · Rafael J. Wysocki
Quoted 3 lines · Viresh Kumar
Also note that
cpufreq_driver->stop_cpu()and ->exit() can get called whilepolicy->rwsemis held. That shouldn't have any side effects though.The last paragraph is unclear.
Is it supposed to mean that the change will cause
cpufreq_driver->stop_cpu()and ->exit() to be called underpolicy->rwsemsometimes?
Yeah, reworded it a bit ..
Also note that, after this patch cpufreq_driver->stop_cpu() and ->exit() will get called while policy->rwsem is held, which wasn't the case earlier. That shouldn't have any side effects though.
Signature · 1 line
viresh
Viresh Kumar
maintainerPATCH v4 3/7 cpufreq: Remove cpufreq_governor_lock
In reply to Viresh KumarWe used to drop policy->rwsem just before calling __cpufreq_governor() in some cases earlier and so it was possible that __cpufreq_governor() runs concurrently via separate threads.
In order to guarantee valid state transitions for governors, 'governor_enabled' was required to be protected using some locking and we created cpufreq_governor_lock for that.
But now, __cpufreq_governor() is always called from within policy->rwsem held and so 'governor_enabled' is protected against races even without cpufreq_governor_lock.
Get rid of the extra lock now.
--- drivers/cpufreq/cpufreq.c | 8 -------- drivers/cpufreq/cpufreq_governor.h | 1 - 2 files changed, 9 deletions(-)
drivers/cpufreq/cpufreq.c +0 -8
@@ -146,8 +146,6 @@ void cpufreq_update_util(u64 time, unsigned long util, unsigned long max)rcu_read_unlock (); } -DEFINE_MUTEX (cpufreq_governor_lock); -/* Flag to suspend/resume CPUFreq governors */ static bool cpufreq_suspended;
@@ -2014,11 +2012,9 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,pr_debug ("%s: for CPU %u, event %u\n" , __func__, policy->cpu, event); -mutex_lock (&cpufreq_governor_lock);if ((policy->governor_enabled && event ==CPUFREQ_GOV_START ) || (!policy->governor_enabled && (event ==CPUFREQ_GOV_LIMITS || event ==CPUFREQ_GOV_STOP ))) { -mutex_unlock (&cpufreq_governor_lock);return -EBUSY ; }
@@ -2027,8 +2023,6 @@ static int __cpufreq_governor(struct cpufreq_policy *policy,else if (event ==CPUFREQ_GOV_START ) policy->governor_enabled = true; -mutex_unlock (&cpufreq_governor_lock); - ret = policy->governor->governor (policy, event);if (!ret) {
@@ -2038,12 +2032,10 @@ static int __cpufreq_governor(struct cpufreq_policy *policy, policy->governor->initialized--; }else {/* Restore original values */ -mutex_lock (&cpufreq_governor_lock);if (event ==CPUFREQ_GOV_STOP ) policy->governor_enabled = true;else if (event ==CPUFREQ_GOV_START ) policy->governor_enabled = false; -mutex_unlock (&cpufreq_governor_lock); } if (((event == CPUFREQ_GOV_POLICY_INIT) && ret) ||
drivers/cpufreq/cpufreq_governor.h +0 -1
@@ -232,7 +232,6 @@ static inline int delay_for_sampling_rate(unsigned int sampling_rate) }extern struct mutex dbs_data_mutex; -extern struct mutex cpufreq_governor_lock;void dbs_check_cpu (struct cpufreq_policy *policy);int cpufreq_governor_dbs (struct cpufreq_policy *policy,unsigned int event); void od_register_powersave_bias_handler(unsigned int (*f)
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 3/7] cpufreq: Remove cpufreq_governor_lock
Quoted 8 lines · Viresh Kumar
We used to drop
policy->rwsemjust before calling__cpufreq_governor()in some cases earlier and so it was possible that__cpufreq_governor()runs concurrently via separate threads.In order to guarantee valid state transitions for governors, '
governor_enabled' was required to be protected using some locking and we createdcpufreq_governor_lockfor that.
Quoted 5 lines
But now,
__cpufreq_governor()is always called from withinpolicy->rwsemheld and so 'governor_enabled' is protected against races even withoutcpufreq_governor_lock.Get rid of the extra lock now.
This one looks good, but depends on the [2/7].
Thanks,
Rafael
Viresh Kumar
maintainerPATCH v4 4/7 cpufreq: governor: Move common sysfs tunables to cpufreq_governor.c
In reply to Viresh KumarWe have got five common sysfs tunables between ondemand and conservative governors, move their callbacks to cpufreq_governor.c to get rid of redundant code.
Because of minor differences in the implementation of the callbacks, some more per-governor callbacks are introduced in order to not introduce any more "governor == ONDEMAND/CONSERVATIVE" like checks.
--- drivers/cpufreq/cpufreq_conservative.c | 80 +++++--------------------- drivers/cpufreq/cpufreq_governor.c | 100 ++++++++++++++++++++++++++++++++ drivers/cpufreq/cpufreq_governor.h | 16 +++++- drivers/cpufreq/cpufreq_ondemand.c | 102 ++++++++------------------------- 4 files changed, 151 insertions(+), 147 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +14 -66
@@ -122,47 +122,17 @@ static struct notifier_block cs_cpufreq_notifier_block = {/************************** sysfs interface ************************/ static struct dbs_governor cs_dbs_gov; -static ssize_t store_sampling_down_factor (struct dbs_data *dbs_data, -const char *buf,size_t count) +static bool invalid_up_threshold (struct dbs_data *dbs_data, +unsigned int threshold) { -unsigned int input; -int ret; - ret =sscanf (buf,"%u" , &input); - -if (ret !=1 || input >MAX_SAMPLING_DOWN_FACTOR || input <1 ) -return -EINVAL ; +struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; - dbs_data->sampling_down_factor = input; -return count; +return threshold >100 || threshold <= cs_tuners->down_threshold; } -static ssize_t store_sampling_rate (struct dbs_data *dbs_data,const char *buf, -size_t count) +static bool invalid_sampling_down_factor (unsigned int factor) { -unsigned int input; -int ret; - ret =sscanf (buf,"%u" , &input); - -if (ret !=1 ) -return -EINVAL ; - - dbs_data->sampling_rate =max (input, dbs_data->min_sampling_rate); -return count; -} - -static ssize_t store_up_threshold (struct dbs_data *dbs_data,const char *buf, -size_t count) -{ -struct cs_dbs_tuners *cs_tuners = dbs_data->tuners; -unsigned int input; -int ret; - ret =sscanf (buf,"%u" , &input); - -if (ret !=1 || input >100 || input <= cs_tuners->down_threshold) -return -EINVAL ; - - dbs_data->up_threshold = input; -return count; +return factor >MAX_SAMPLING_DOWN_FACTOR ; } static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf,
@@ -182,27 +152,13 @@ static ssize_t store_down_threshold(struct dbs_data *dbs_data, const char *buf,return count; } -static ssize_t store_ignore_nice_load (struct dbs_data *dbs_data, -const char *buf,size_t count) +static void update_ignore_nice_load (struct dbs_data *dbs_data) { -unsigned int input, j; -int ret; - - ret =sscanf (buf,"%u" , &input); -if (ret !=1 ) -return -EINVAL ; - -if (input >1 ) - input =1 ; - -if (input == dbs_data->ignore_nice_load)/* nothing to do */ -return count; - - dbs_data->ignore_nice_load = input; +struct cs_cpu_dbs_info_s *dbs_info; +unsigned int j;/* we need to re-evaluate prev_cpu_idle */ for_each_online_cpu (j) { -struct cs_cpu_dbs_info_s *dbs_info; dbs_info = &per_cpu (cs_cpu_dbs_info, j); dbs_info->cdbs.prev_cpu_idle =get_cpu_idle_time (j, &dbs_info->cdbs.prev_cpu_wall,0 );
@@ -210,7 +166,6 @@ static ssize_t store_ignore_nice_load(struct dbs_data *dbs_data, dbs_info->cdbs.prev_cpu_nice =kcpustat_cpu (j).cpustat[CPUTIME_NICE ]; } -return count; } static ssize_t store_freq_step(struct dbs_data *dbs_data, const char *buf,
@@ -235,21 +190,11 @@ static ssize_t store_freq_step(struct dbs_data *dbs_data, const char *buf,return count; } -gov_show_one_common (sampling_rate); -gov_show_one_common (sampling_down_factor); -gov_show_one_common (up_threshold); -gov_show_one_common (ignore_nice_load); -gov_show_one_common (min_sampling_rate);gov_show_one (cs, down_threshold);gov_show_one (cs, freq_step); -gov_attr_rw (sampling_rate); -gov_attr_rw (sampling_down_factor); -gov_attr_rw (up_threshold); -gov_attr_rw (ignore_nice_load); -gov_attr_ro (min_sampling_rate); -gov_attr_rw (down_threshold); -gov_attr_rw (freq_step); +static gov_attr_rw (down_threshold); +static gov_attr_rw (freq_step);static struct attribute *cs_attributes[] = { &min_sampling_rate.attr,
@@ -315,6 +260,9 @@ static struct dbs_governor cs_dbs_gov = { .get_cpu_dbs_info_s = get_cpu_dbs_info_s, .gov_dbs_timer = cs_dbs_timer, .gov_check_cpu = cs_check_cpu, + .invalid_up_threshold = invalid_up_threshold, + .invalid_sampling_down_factor = invalid_sampling_down_factor, + .update_ignore_nice_load = update_ignore_nice_load, .init = cs_init, .exit = cs_exit, };
drivers/cpufreq/cpufreq_governor.c +100 -0
112 lines not on this page · raw message
drivers/cpufreq/cpufreq_governor.h +14 -2
@@ -64,6 +64,7 @@ static void *get_cpu_dbs_info_s(int cpu) \/* Governor demand based switching data (per-policy or global). */ struct dbs_data { +struct dbs_governor *gov;int usage_count;void *tuners;unsigned int min_sampling_rate;
@@ -106,13 +107,19 @@ static ssize_t show_##file_name \ }#define gov_attr_ro (_name) \ -static struct governor_attr _name = \ +struct governor_attr _name = \ __ATTR(_name, 0444, show_##_name, NULL)#define gov_attr_rw (_name) \ -static struct governor_attr _name = \ +struct governor_attr _name = \ __ATTR(_name, 0644, show_##_name, store_##_name) +extern struct governor_attr sampling_rate; +extern struct governor_attr up_threshold; +extern struct governor_attr sampling_down_factor; +extern struct governor_attr ignore_nice_load; +extern struct governor_attr min_sampling_rate; +/* Common to all CPUs of a policy */ struct policy_dbs_info {struct cpufreq_policy *policy;
@@ -202,6 +209,11 @@ struct dbs_governor {void (*gov_check_cpu)(int cpu,unsigned int load);int (*init)(struct dbs_data *dbs_data,bool notify);void (*exit)(struct dbs_data *dbs_data,bool notify); +bool (*invalid_up_threshold)(struct dbs_data *dbs_data,unsigned int threshold); +bool (*invalid_sampling_down_factor)(unsigned int factor); +void (*update_sampling_rate)(struct dbs_data *dbs_data); +void (*update_sampling_down_factor)(struct dbs_data *dbs_data); +void (*update_ignore_nice_load)(struct dbs_data *dbs_data);/* Governor specific ops, see below */ void *gov_ops;
drivers/cpufreq/cpufreq_ondemand.c +23 -79
166 lines not on this page · raw message
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 4/7] cpufreq: governor: Move common sysfs tunables to cpufreq_governor.c
Quoted 11 lines · Viresh Kumar
We have got five common sysfs tunables between ondemand and conservative governors, move their callbacks to
cpufreq_governor.cto get rid of redundant code.Because of minor differences in the implementation of the callbacks, some more per-governor callbacks are introduced in order to not introduce any more "governor == ONDEMAND/CONSERVATIVE" like checks.
Signed-off-by Viresh Kumar <[email protected]>Tested-by Juri Lelli <[email protected]>Tested-by Shilpasri G Bhat <[email protected]>
To me, the benefit from this patch is marginal and the cost is quite substantial.
The code is really only duplicate if both governors are non-modular or their modules are both loaded at the same time and it's not worth adding the new governor callbacks IMO.
If the implementation of the given show/store pair is different enough that you need an extra callback to move them to _governor.c, I won't bother doing that.
Thanks,
Rafael
Viresh Kumar
maintainerPATCH v5 1/3 cpufreq: governor: No need to manage state machine now
The cpufreq core now guarantees that policy->rwsem won't be dropped while running the ->governor callback for the CPUFREQ_GOV_POLICY_EXIT event and will be held acquired until the complete sequence of governor state changes has finished.
This allows governor state machine checks to be dropped from multiple functions in cpufreq_governor.c.
This also means that policy_dbs->policy can be initialized upfront, so the entire initialization of struct policy_dbs is carried out in one place.
---
Rafael,
The 4th patch is dropped and 5-7 are updated on top of that.
drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/cpufreq/cpufreq_governor.c +5 -22
@@ -233,8 +233,10 @@ static inline void gov_clear_update_util(struct cpufreq_policy *policy)synchronize_rcu (); } -static void gov_cancel_work (struct policy_dbs_info *policy_dbs) +static void gov_cancel_work (struct cpufreq_policy *policy) { +struct policy_dbs_info *policy_dbs = policy->governor_data; +/* Tell dbs_update_util_handler() to skip queuing up work items. */ atomic_inc (&policy_dbs->skip_work);/*
@@ -330,6 +332,7 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poliif (!policy_dbs)return NULL ; + policy_dbs->policy = policy;mutex_init (&policy_dbs->timer_mutex);atomic_set (&policy_dbs->skip_work,0 );init_irq_work (&policy_dbs->irq_work, dbs_irq_work);
@@ -460,10 +463,6 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy)struct dbs_data *dbs_data = policy_dbs->dbs_data;int count; -/* State should be equivalent to INIT */ -if (policy_dbs->policy) -return -EBUSY ; -mutex_lock (&dbs_data->mutex);list_del (&policy_dbs->list); count = --dbs_data->usage_count;
@@ -499,10 +498,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)if (!policy->cur)return -EINVAL ; -/* State should be equivalent to INIT */ -if (policy_dbs->policy) -return -EBUSY ; - sampling_rate = dbs_data->sampling_rate; ignore_nice = dbs_data->ignore_nice_load;
@@ -527,7 +522,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)if (ignore_nice) j_cdbs->prev_cpu_nice =kcpustat_cpu (j).cpustat[CPUTIME_NICE ]; } - policy_dbs->policy = policy;if (gov->governor ==GOV_CONSERVATIVE ) { struct cs_cpu_dbs_info_s *cs_dbs_info =
@@ -550,14 +544,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)static int cpufreq_governor_stop (struct cpufreq_policy *policy) { -struct policy_dbs_info *policy_dbs = policy->governor_data; - -/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; - -gov_cancel_work (policy_dbs); - policy_dbs->policy =NULL ; +gov_cancel_work (policy);return 0 ; }
@@ -566,10 +553,6 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy) {struct policy_dbs_info *policy_dbs = policy->governor_data; -/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; -mutex_lock (&policy_dbs->timer_mutex);if (policy->max < policy->cur)__cpufreq_driver_target (policy, policy->max,CPUFREQ_RELATION_H );
Signature · 1 line
2.7.1.370.gb2aa7f8
Viresh Kumar
maintainerPATCH v5 2/3 cpufreq: conservative: Update sample_delay_ns immediately
Ondemand governor already updates sample_delay_ns immediately on updates to sampling rate, but conservative isn't doing that.
It was left out earlier as the code has been really complex to get that done easily. But now things are sorted out very well, and we can follow the same for conservative governor as well.
--- drivers/cpufreq/cpufreq_conservative.c | 14 ------- drivers/cpufreq/cpufreq_governor.c | 63 +++++++++++++++++++++++++++++++ drivers/cpufreq/cpufreq_governor.h | 2 + drivers/cpufreq/cpufreq_ondemand.c | 69 ---------------------------------- 4 files changed, 65 insertions(+), 83 deletions(-)
drivers/cpufreq/cpufreq_conservative.c +0 -14
@@ -136,20 +136,6 @@ static ssize_t store_sampling_down_factor(struct dbs_data *dbs_data,return count; } -static ssize_t store_sampling_rate (struct dbs_data *dbs_data,const char *buf, -size_t count) -{ -unsigned int input; -int ret; - ret =sscanf (buf,"%u" , &input); - -if (ret !=1 ) -return -EINVAL ; - - dbs_data->sampling_rate =max (input, dbs_data->min_sampling_rate); -return count; -} -static ssize_t store_up_threshold (struct dbs_data *dbs_data,const char *buf,size_t count) {
drivers/cpufreq/cpufreq_governor.c +63 -0
69 lines not on this page · raw message
drivers/cpufreq/cpufreq_governor.h +2 -0
@@ -238,4 +238,6 @@ void od_register_powersave_bias_handler(unsigned int (*f) (struct cpufreq_policy *, unsigned int, unsigned int), unsigned int powersave_bias);void od_unregister_powersave_bias_handler (void ); +ssize_t store_sampling_rate (struct dbs_data *dbs_data,const char *buf, +size_t count);#endif /* _CPUFREQ_GOVERNOR_H */
drivers/cpufreq/cpufreq_ondemand.c +0 -69
75 lines not on this page · raw message
Signature · 1 line
2.7.1.370.gb2aa7f8
Viresh Kumar
maintainerPATCH v5 3/3 cpufreq: ondemand: Rearrange od_dbs_timer() to avoid updating delay
In reply to Viresh Kumar'delay' is updated properly in all paths of the routine od_dbs_timer(), leaving just one. And can be 0 only in that case.
Move the update to 'delay' as an else part of the if block.
--- drivers/cpufreq/cpufreq_ondemand.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/cpufreq/cpufreq_ondemand.c +4 -5
@@ -194,7 +194,7 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)struct policy_dbs_info *policy_dbs = policy->governor_data;struct dbs_data *dbs_data = policy_dbs->dbs_data;struct od_cpu_dbs_info_s *dbs_info = &per_cpu (od_cpu_dbs_info, policy->cpu); -int delay =0 , sample_type = dbs_info->sample_type; +int delay, sample_type = dbs_info->sample_type;/* Common NORMAL_SAMPLE setup */ dbs_info->sample_type =OD_NORMAL_SAMPLE ;
@@ -208,13 +208,12 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)/* Setup timer for SUB_SAMPLE */ dbs_info->sample_type =OD_SUB_SAMPLE ; delay = dbs_info->freq_hi_jiffies; + }else { + delay =delay_for_sampling_rate (dbs_data->sampling_rate + * dbs_info->rate_mult); } } -if (!delay) - delay =delay_for_sampling_rate (dbs_data->sampling_rate - * dbs_info->rate_mult); -return delay; }
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V5 1/3] cpufreq: governor: No need to manage state machine now
In reply to Viresh KumarQuoted 12 lines · Viresh Kumar
The cpufreq core now guarantees that
policy->rwsemwon't be dropped while running the ->governor callback for theCPUFREQ_GOV_POLICY_EXITevent and will be held acquired until the complete sequence of governor state changes has finished.This allows governor state machine checks to be dropped from multiple functions in
cpufreq_governor.c.This also means that
policy_dbs->policycan be initialized upfront, so the entire initialization of structpolicy_dbsis carried out in one place.
Quoted 7 lines
Signed-off-by Viresh Kumar <[email protected]>Tested-by Juri Lelli <[email protected]>Tested-by Shilpasri G Bhat <[email protected]>---
Rafael,The 4th patch is dropped and 5-7 are updated on top of that.
There are some comments to address on the changelogs of patches [1-2/7], so can you address them and resend the whole series, please?
Thanks,
Rafael
Viresh Kumar
maintainerPATCH v4 5/7 cpufreq: governor: No need to manage state machine now
In reply to Viresh Kumarcpufreq core now guarantees that policy->rwsem wouldn't get dropped while calling CPUFREQ_GOV_POLICY_EXIT governor event and will be kept acquired until the complete sequence of governor state changes has finished.
And so we can remove the state machine checks that were put in place earlier.
This also means that policy_dbs->policy can be initialized while policy_dbs is allocated, to move all initialization together.
--- drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)
drivers/cpufreq/cpufreq_governor.c +5 -22
@@ -332,8 +332,10 @@ static inline void gov_clear_update_util(struct cpufreq_policy *policy)synchronize_rcu (); } -static void gov_cancel_work (struct policy_dbs_info *policy_dbs) +static void gov_cancel_work (struct cpufreq_policy *policy) { +struct policy_dbs_info *policy_dbs = policy->governor_data; +/* Tell dbs_update_util_handler() to skip queuing up work items. */ atomic_inc (&policy_dbs->skip_work);/*
@@ -429,6 +431,7 @@ static struct policy_dbs_info *alloc_policy_dbs_info(struct cpufreq_policy *poliif (!policy_dbs)return NULL ; + policy_dbs->policy = policy;mutex_init (&policy_dbs->timer_mutex);atomic_set (&policy_dbs->skip_work,0 );init_irq_work (&policy_dbs->irq_work, dbs_irq_work);
@@ -560,10 +563,6 @@ static int cpufreq_governor_exit(struct cpufreq_policy *policy)struct dbs_data *dbs_data = policy_dbs->dbs_data;int count; -/* State should be equivalent to INIT */ -if (policy_dbs->policy) -return -EBUSY ; -mutex_lock (&dbs_data->mutex);list_del (&policy_dbs->list); count = dbs_data->usage_count--;
@@ -599,10 +598,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)if (!policy->cur)return -EINVAL ; -/* State should be equivalent to INIT */ -if (policy_dbs->policy) -return -EBUSY ; - sampling_rate = dbs_data->sampling_rate; ignore_nice = dbs_data->ignore_nice_load;
@@ -627,7 +622,6 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)if (ignore_nice) j_cdbs->prev_cpu_nice =kcpustat_cpu (j).cpustat[CPUTIME_NICE ]; } - policy_dbs->policy = policy;if (gov->governor ==GOV_CONSERVATIVE ) { struct cs_cpu_dbs_info_s *cs_dbs_info =
@@ -650,14 +644,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)static int cpufreq_governor_stop (struct cpufreq_policy *policy) { -struct policy_dbs_info *policy_dbs = policy->governor_data; - -/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; - -gov_cancel_work (policy_dbs); - policy_dbs->policy =NULL ; +gov_cancel_work (policy);return 0 ; }
@@ -666,10 +653,6 @@ static int cpufreq_governor_limits(struct cpufreq_policy *policy) {struct policy_dbs_info *policy_dbs = policy->governor_data; -/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; -mutex_lock (&policy_dbs->timer_mutex);if (policy->max < policy->cur)__cpufreq_driver_target (policy, policy->max,CPUFREQ_RELATION_H );
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 5/7] cpufreq: governor: No need to manage state machine now
Quoted 1 line · Viresh Kumar
cpufreq core now guarantees that
policy->rwsemwouldn't get dropped
"The cpufreq core ..." and "won't be dropped"
Quoted 1 line
while calling
CPUFREQ_GOV_POLICY_EXITgovernor event and will be kept
"while running the ->governor callback for the CPUFREQ_GOV_POLICY_EXIT event and will be held"
Quoted 5 lines
acquired until the complete sequence of governor state changes has finished.
And so we can remove the state machine checks that were put in place earlier.
"This allows governor state machine checks to be dropped from multiple functions in cpufreq_governor.c."
Quoted 2 lines
This also means that
policy_dbs->policycan be initialized while
"initialized upfront"
Quoted 1 line
policy_dbsis allocated, to move all initialization together.
"so the entire initialization of struct policy_dbs is carried out in one place."
Quoted 10 lines
Signed-off-by Viresh Kumar <[email protected]>Tested-by Juri Lelli <[email protected]>Tested-by Shilpasri G Bhat <[email protected]>--- drivers/cpufreq/cpufreq_governor.c | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-)drivers/cpufreq/cpufreq_governor.c +0
-0
[cut]
Quoted 6 lines
drivers/cpufreq/cpufreq_governor.c +0
-2@@ -650,14 +644,7 @@ static int cpufreq_governor_start(struct cpufreq_policy *policy)static int cpufreq_governor_stop (struct cpufreq_policy *policy) { -struct policy_dbs_info *policy_dbs = policy->governor_data; -
drivers/cpufreq/cpufreq_governor.c static int cpufreq_governor_start(struct cpufreq_policy *policy) · line 650
Quoted 10 lines
drivers/cpufreq/cpufreq_governor.c +1
-6-/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; - -gov_cancel_work (policy_dbs); - policy_dbs->policy =NULL ; +gov_cancel_work (policy);return 0 ; }
So maybe we can call gov_cancel_work(policy) from cpufreq_governor_dbs() directly and get rid of this wrapper too?
Thanks,
Rafael
Viresh Kumar
maintainerRe: [PATCH V4 5/7] cpufreq: governor: No need to manage state machine now
Quoted 12 lines · Rafael J. Wysocki
Quoted 12 lines
static int
cpufreq_governor_stop(struct cpufreq_policy *policy){drivers/cpufreq/cpufreq_governor.c +1
-8-struct policy_dbs_info *policy_dbs = policy->governor_data; - -/* State should be equivalent to START */ -if (!policy_dbs->policy) -return -EBUSY ; - -gov_cancel_work (policy_dbs); - policy_dbs->policy =NULL ; +gov_cancel_work (policy);
Quoted 5 lines
Quoted 2 lines
return 0;}
So maybe we can call
gov_cancel_work(policy)fromcpufreq_governor_dbs()directly and get rid of this wrapper too?
I thought about it, but left it for consistency. It wouldn't hurt, the compiler will anyway make it inline I believe.
Signature · 1 line
viresh
Viresh Kumar
maintainerPATCH v4 6/7 cpufreq: conservative: Update sample_delay_ns immediately
In reply to Viresh KumarOndemand governor already updates sample_delay_ns immediately on updates to sampling rate, but conservative isn't doing that.
It was left out earlier as the code has been really complex to get that done easily. But now things are sorted out very well, and we can follow the same for conservative governor as well.
--- drivers/cpufreq/cpufreq_governor.c | 49 ++++++++++++++++++++++++++++++++--- drivers/cpufreq/cpufreq_governor.h | 1 - drivers/cpufreq/cpufreq_ondemand.c | 52 -------------------------------------- 3 files changed, 46 insertions(+), 56 deletions(-)
drivers/cpufreq/cpufreq_governor.c +46 -3
@@ -26,10 +26,29 @@ DEFINE_MUTEX(dbs_data_mutex);EXPORT_SYMBOL_GPL (dbs_data_mutex);/* Common sysfs tunables */ +/** +* update_sampling_rate - update sampling rate effective immediately if needed. +* +* If new rate is smaller than the old, simply updating +* dbs.sampling_rate might not be appropriate. For example, if the +* original sampling_rate was 1 second and the requested new sampling rate is 10 +* ms because the user needs immediate reaction from ondemand governor, but not +* sure if higher frequency will be required or not, then, the governor may +* change the sampling rate too late; up to 1 second later. Thus, if we are +* reducing the sampling rate, we need to make the new value effective +* immediately. +* +* On the other hand, if new rate is larger than the old, then we may evaluate +* the load too soon, and it might we worth updating sample_delay_ns then as +* well. +* +* This must be called with dbs_data->mutex held, otherwise traversing +* policy_dbs_list isn't safe. +*/ static ssize_t store_sampling_rate (struct dbs_data *dbs_data,const char *buf,size_t count) { -struct dbs_governor *gov = dbs_data->gov; +struct policy_dbs_info *policy_dbs;unsigned int rate;int ret; ret =sscanf (buf,"%u" , &rate);
@@ -38,8 +57,32 @@ static ssize_t store_sampling_rate(struct dbs_data *dbs_data, const char *buf, dbs_data->sampling_rate =max (rate, dbs_data->min_sampling_rate); -if (gov->update_sampling_rate) - gov->update_sampling_rate (dbs_data); +/* +* We are operating under dbs_data->mutex and so the list and its +* entries can't be freed concurrently. +*/ +list_for_each_entry (policy_dbs, &dbs_data->policy_dbs_list, list) { +mutex_lock (&policy_dbs->timer_mutex); +/* +* On 32-bit architectures this may race with the +* sample_delay_ns read in dbs_update_util_handler(), but that +* really doesn't matter. If the read returns a value that's +* too big, the sample will be skipped, but the next invocation +* of dbs_update_util_handler() (when the update has been +* completed) will take a sample. If the returned value is too +* small, the sample will be taken immediately, but that isn't a +* problem, as we want the new rate to take effect immediately +* anyway. +* +* If this runs in parallel with dbs_work_handler(), we may end +* up overwriting the sample_delay_ns value that it has just +* written, but the difference should not be too big and it will +* be corrected next time a sample is taken, so it shouldn't be +* significant. +*/ +gov_update_sample_delay (policy_dbs, dbs_data->sampling_rate); +mutex_unlock (&policy_dbs->timer_mutex); + }return count; }
drivers/cpufreq/cpufreq_governor.h +0 -1
@@ -211,7 +211,6 @@ struct dbs_governor {void (*exit)(struct dbs_data *dbs_data,bool notify);bool (*invalid_up_threshold)(struct dbs_data *dbs_data,unsigned int threshold);bool (*invalid_sampling_down_factor)(unsigned int factor); -void (*update_sampling_rate)(struct dbs_data *dbs_data);void (*update_sampling_down_factor)(struct dbs_data *dbs_data);void (*update_ignore_nice_load)(struct dbs_data *dbs_data);
drivers/cpufreq/cpufreq_ondemand.c +0 -52
64 lines not on this page · raw message
Signature · 1 line
2.7.1.370.gb2aa7f8
Viresh Kumar
maintainerPATCH v4 7/7 cpufreq: ondemand: Rearrange od_dbs_timer() to void updating delay
In reply to Viresh Kumar'delay' is updated properly in all paths of the routine od_dbs_timer(), leaving just one. And can be 0 only in that case.
Move the update to 'delay' as an else part of the if block.
--- drivers/cpufreq/cpufreq_ondemand.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
drivers/cpufreq/cpufreq_ondemand.c +4 -5
@@ -194,7 +194,7 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)struct policy_dbs_info *policy_dbs = policy->governor_data;struct dbs_data *dbs_data = policy_dbs->dbs_data;struct od_cpu_dbs_info_s *dbs_info = &per_cpu (od_cpu_dbs_info, policy->cpu); -int delay =0 , sample_type = dbs_info->sample_type; +int delay, sample_type = dbs_info->sample_type;/* Common NORMAL_SAMPLE setup */ dbs_info->sample_type =OD_NORMAL_SAMPLE ;
@@ -208,13 +208,12 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)/* Setup timer for SUB_SAMPLE */ dbs_info->sample_type =OD_SUB_SAMPLE ; delay = dbs_info->freq_hi_jiffies; + }else { + delay =delay_for_sampling_rate (dbs_data->sampling_rate + * dbs_info->rate_mult); } } -if (!delay) - delay =delay_for_sampling_rate (dbs_data->sampling_rate - * dbs_info->rate_mult); -return delay; }
Signature · 1 line
2.7.1.370.gb2aa7f8
Rafael J. Wysocki
maintainerRe: [PATCH V4 7/7] cpufreq: ondemand: Rearrange od_dbs_timer() to void updating delay
s/void/avoid/ in the subject.
Apart from that it looks good.
Quoted 47 lines · Viresh Kumar
'delay' is updated properly in all paths of the routine
od_dbs_timer(), leaving just one. And can be 0 only in that case.Move the update to 'delay' as an else part of the if block.
Signed-off-by Viresh Kumar <[email protected]>--- drivers/cpufreq/cpufreq_ondemand.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)drivers/cpufreq/cpufreq_ondemand.c +4
-6@@ -194,7 +194,7 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)struct policy_dbs_info *policy_dbs = policy->governor_data;struct dbs_data *dbs_data = policy_dbs->dbs_data;struct od_cpu_dbs_info_s *dbs_info = &per_cpu (od_cpu_dbs_info, policy->cpu); -int delay =0 , sample_type = dbs_info->sample_type; +int delay, sample_type = dbs_info->sample_type;/* Common NORMAL_SAMPLE setup */ dbs_info->sample_type =OD_NORMAL_SAMPLE ;@@ -208,13 +208,12 @@ static unsigned int od_dbs_timer(struct cpufreq_policy *policy)/* Setup timer for SUB_SAMPLE */ dbs_info->sample_type =OD_SUB_SAMPLE ; delay = dbs_info->freq_hi_jiffies; + }else { + delay =delay_for_sampling_rate (dbs_data->sampling_rate + * dbs_info->rate_mult); } } -if (!delay) - delay =delay_for_sampling_rate (dbs_data->sampling_rate - * dbs_info->rate_mult); -return delay; } --2.7.1.370.gb2aa7f8
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html