Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1329878 > unrolled thread
| Started by | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| First post | 2016-02-09 04:50 +0100 |
| Last post | 2016-02-11 11:00 +0100 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH V4 3/7] cpufreq: Remove cpufreq_governor_lock Viresh Kumar <viresh.kumar@linaro.org> - 2016-02-09 04:50 +0100
Re: [PATCH V4 3/7] cpufreq: Remove cpufreq_governor_lock "Rafael J. Wysocki" <rafael@kernel.org> - 2016-02-11 11:00 +0100
| From | Viresh Kumar <viresh.kumar@linaro.org> |
|---|---|
| Date | 2016-02-09 04:50 +0100 |
| Subject | [PATCH V4 3/7] cpufreq: Remove cpufreq_governor_lock |
| Message-ID | <r07tn-6FT-1@gated-at.bofh.it> |
We 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.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Tested-by: Juri Lelli <juri.lelli@arm.com>
Tested-by: Shilpasri G Bhat <shilpa.bhat@linux.vnet.ibm.com>
---
drivers/cpufreq/cpufreq.c | 8 --------
drivers/cpufreq/cpufreq_governor.h | 1 -
2 files changed, 9 deletions(-)
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 51fb47cd38a0..745da90d7b38 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -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) ||
diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
index 4e77efb7db67..02885e353dfc 100644
--- a/drivers/cpufreq/cpufreq_governor.h
+++ b/drivers/cpufreq/cpufreq_governor.h
@@ -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)
--
2.7.1.370.gb2aa7f8
[toc] | [next] | [standalone]
| From | "Rafael J. Wysocki" <rafael@kernel.org> |
|---|---|
| Date | 2016-02-11 11:00 +0100 |
| Message-ID | <r0WcA-6ZA-21@gated-at.bofh.it> |
| In reply to | #1329878 |
On Tue, Feb 9, 2016 at 4:46 AM, Viresh Kumar <viresh.kumar@linaro.org> wrote: > We 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. This one looks good, but depends on the [2/7]. Thanks, Rafael
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web