Re: [PATCH] cpufreq, store_scaling_governor requires policy->rwsem to be held for duration of changing governors [v2]

From: Viresh Kumar
Date: Thu Aug 07 2014 - 02:36:42 EST


On 6 August 2014 20:38, Stephen Boyd <sboyd@xxxxxxxxxxxxxx> wrote:
> On 08/06, Prarit Bhargava wrote:
> > Are you sure you're not seeing another lockdep warning? That was my problem --
> > there was an xfs related lockdep warning which then resulted in lockdep being
> > disabled from that point on.

There is a fair chance that I might be doing something really really stupid,
but I couldn't get the lockdep warning..

> Are we talking about the lockdep splat or the crash that started
> this thread or something else? For the lockdep splat you need the
> corrected patch in this thread and the per policy governor flag.
> I'm not sure how to recreate the crash that started this thread.

We are talking about the lockdep splat that would happen if we don't
drop locking around EXIT..

This is my full diff over mainline and my .config is attached.
Please enlighten me on what am I missing :)

diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
index 6f02485..fa11a7d 100644
--- a/drivers/cpufreq/cpufreq.c
+++ b/drivers/cpufreq/cpufreq.c
@@ -2200,9 +2200,7 @@ static int cpufreq_set_policy(struct
cpufreq_policy *policy,
/* end old governor */
if (old_gov) {
__cpufreq_governor(policy, CPUFREQ_GOV_STOP);
- up_write(&policy->rwsem);
__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
- down_write(&policy->rwsem);
}

/* start new governor */
@@ -2211,9 +2209,7 @@ static int cpufreq_set_policy(struct
cpufreq_policy *policy,
if (!__cpufreq_governor(policy, CPUFREQ_GOV_START))
goto out;

- up_write(&policy->rwsem);
__cpufreq_governor(policy, CPUFREQ_GOV_POLICY_EXIT);
- down_write(&policy->rwsem);
}

/* new governor failed, so re-start old one */
diff --git a/drivers/cpufreq/exynos-cpufreq.c b/drivers/cpufreq/exynos-cpufreq.c
index 1e0ec57..027b6f7 100644
--- a/drivers/cpufreq/exynos-cpufreq.c
+++ b/drivers/cpufreq/exynos-cpufreq.c
@@ -139,7 +139,7 @@ static int exynos_cpufreq_cpu_init(struct
cpufreq_policy *policy)
}

static struct cpufreq_driver exynos_driver = {
- .flags = CPUFREQ_STICKY | CPUFREQ_NEED_INITIAL_FREQ_CHECK,
+ .flags = CPUFREQ_STICKY |
CPUFREQ_NEED_INITIAL_FREQ_CHECK | CPUFREQ_HAVE_GOVERNOR_PER_POLICY,
.verify = cpufreq_generic_frequency_table_verify,
.target_index = exynos_target,
.get = cpufreq_generic_get,

Attachment: exynos-lockdep-config
Description: Binary data