diff mbox

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

Message ID CAKohponBRn9mwpPMinsjqpHe3wTFj6aNpYk5gZaWDKht3bd5NQ@mail.gmail.com
State New
Headers show

Commit Message

Viresh Kumar Aug. 7, 2014, 6:36 a.m. UTC
On 6 August 2014 20:38, Stephen Boyd <sboyd@codeaurora.org> 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 :)

        .target_index   = exynos_target,
        .get            = cpufreq_generic_get,

Comments

Prarit Bhargava Aug. 7, 2014, 10:12 a.m. UTC | #1
On 08/07/2014 02:36 AM, Viresh Kumar wrote:
> On 6 August 2014 20:38, Stephen Boyd <sboyd@codeaurora.org> 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 :)

That should have done it.  What are your CPUFREQ configs?

P.

> 
> 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,
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Aug. 7, 2014, 10:15 a.m. UTC | #2
On 7 August 2014 15:42, Prarit Bhargava <prarit@redhat.com> wrote:
> That should have done it.  What are your CPUFREQ configs?

You can check the same .config I attached last time for that :)

CONFIG_CPU_FREQ=y
CONFIG_CPU_FREQ_GOV_COMMON=y
CONFIG_CPU_FREQ_STAT=y
CONFIG_CPU_FREQ_STAT_DETAILS=y
# CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
# CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE=y
CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
CONFIG_CPU_FREQ_GOV_POWERSAVE=y
CONFIG_CPU_FREQ_GOV_USERSPACE=y
CONFIG_CPU_FREQ_GOV_ONDEMAND=y
CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y


Anyway, has anybody tried to test what I have been trying now?
@Prarit: You can try that on your x86 box as well, which has a
single cluster or group of CPUs sharing clock line.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Aug. 12, 2014, 9:03 a.m. UTC | #3
On 7 August 2014 15:45, Viresh Kumar <viresh.kumar@linaro.org> wrote:
> On 7 August 2014 15:42, Prarit Bhargava <prarit@redhat.com> wrote:
>> That should have done it.  What are your CPUFREQ configs?
>
> You can check the same .config I attached last time for that :)
>
> CONFIG_CPU_FREQ=y
> CONFIG_CPU_FREQ_GOV_COMMON=y
> CONFIG_CPU_FREQ_STAT=y
> CONFIG_CPU_FREQ_STAT_DETAILS=y
> # CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE is not set
> # CONFIG_CPU_FREQ_DEFAULT_GOV_USERSPACE is not set
> # CONFIG_CPU_FREQ_DEFAULT_GOV_ONDEMAND is not set
> CONFIG_CPU_FREQ_DEFAULT_GOV_CONSERVATIVE=y
> CONFIG_CPU_FREQ_GOV_PERFORMANCE=y
> CONFIG_CPU_FREQ_GOV_POWERSAVE=y
> CONFIG_CPU_FREQ_GOV_USERSPACE=y
> CONFIG_CPU_FREQ_GOV_ONDEMAND=y
> CONFIG_CPU_FREQ_GOV_CONSERVATIVE=y
>
>
> Anyway, has anybody tried to test what I have been trying now?
> @Prarit: You can try that on your x86 box as well, which has a
> single cluster or group of CPUs sharing clock line.

Ping!!
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/
Viresh Kumar Aug. 13, 2014, 7:39 a.m. UTC | #4
On 12 August 2014 17:03, Prarit Bhargava <prarit@redhat.com> wrote:
> Okay, this is what I have and I can reproduce this *easily* 100% of the time.
>
> I've used your above config options and have enabled LOCKDEP.
>
> In order to restore the locking, I've applied the following patch to the cpufreq
> core (sorry for the cut-and-paste):
>
> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
> index d9fdedd..dfda238 100644
> --- a/drivers/cpufreq/cpufreq.c
> +++ b/drivers/cpufreq/cpufreq.c
> @@ -2192,9 +2192,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *polic
>         /* 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 */
> @@ -2203,9 +2201,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *polic
>                 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 */
>
>
> I've modified the acpi-cpufreq driver to include (sorry for the cut-and-paste)
>
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
> index b0c18ed..97653c3 100644
> --- a/drivers/cpufreq/acpi-cpufreq.c
> +++ b/drivers/cpufreq/acpi-cpufreq.c
> @@ -884,6 +884,9 @@ static struct freq_attr *acpi_cpufreq_attr[] = {
>  };
>
>  static struct cpufreq_driver acpi_cpufreq_driver = {
> +       .flags                  = CPUFREQ_STICKY |
> +                                       CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
> +                                       CPUFREQ_NEED_INITIAL_FREQ_CHECK,
>         .verify         = cpufreq_generic_frequency_table_verify,
>         .target_index   = acpi_cpufreq_target,
>         .bios_limit     = acpi_processor_get_bios_limit,
>
> I do a
>
> cat /sys/devices/system/cpu/cpu2/cpufreq/conservative/*
> echo ondemand > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
>
> and then I immediately see the stack trace.

What's your system configuration? How many clusters/cpus/etc..
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Prarit Bhargava Aug. 13, 2014, 9:58 a.m. UTC | #5
On 08/13/2014 03:39 AM, Viresh Kumar wrote:
> On 12 August 2014 17:03, Prarit Bhargava <prarit@redhat.com> wrote:
>> Okay, this is what I have and I can reproduce this *easily* 100% of the time.
>>
>> I've used your above config options and have enabled LOCKDEP.
>>
>> In order to restore the locking, I've applied the following patch to the cpufreq
>> core (sorry for the cut-and-paste):
>>
>> diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
>> index d9fdedd..dfda238 100644
>> --- a/drivers/cpufreq/cpufreq.c
>> +++ b/drivers/cpufreq/cpufreq.c
>> @@ -2192,9 +2192,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *polic
>>         /* 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 */
>> @@ -2203,9 +2201,7 @@ static int cpufreq_set_policy(struct cpufreq_policy *polic
>>                 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 */
>>
>>
>> I've modified the acpi-cpufreq driver to include (sorry for the cut-and-paste)
>>
>> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
>> index b0c18ed..97653c3 100644
>> --- a/drivers/cpufreq/acpi-cpufreq.c
>> +++ b/drivers/cpufreq/acpi-cpufreq.c
>> @@ -884,6 +884,9 @@ static struct freq_attr *acpi_cpufreq_attr[] = {
>>  };
>>
>>  static struct cpufreq_driver acpi_cpufreq_driver = {
>> +       .flags                  = CPUFREQ_STICKY |
>> +                                       CPUFREQ_HAVE_GOVERNOR_PER_POLICY |
>> +                                       CPUFREQ_NEED_INITIAL_FREQ_CHECK,
>>         .verify         = cpufreq_generic_frequency_table_verify,
>>         .target_index   = acpi_cpufreq_target,
>>         .bios_limit     = acpi_processor_get_bios_limit,
>>
>> I do a
>>
>> cat /sys/devices/system/cpu/cpu2/cpufreq/conservative/*
>> echo ondemand > /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor
>>
>> and then I immediately see the stack trace.
> 
> What's your system configuration? How many clusters/cpus/etc..

Anywhere from 2-4 sockets, 8 - 240 cpus (depending on # of sockets), x86 arch.

P.
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Viresh Kumar Aug. 14, 2014, 4:19 a.m. UTC | #6
On 13 August 2014 15:28, Prarit Bhargava <prarit@redhat.com> wrote:
> Anywhere from 2-4 sockets, 8 - 240 cpus (depending on # of sockets), x86 arch.

That's what. We know that it does happen on multi cluster systems
and I was reproducing it on a single cluster one. i.e. all CPUs share
clock line.
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,