2015-06-24 06:49:53

by Preeti U Murthy

[permalink] [raw]
Subject: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On some archs, the local clockevent device stops in deep cpuidle states.
The broadcast framework is used to wakeup cpus in these idle states, in
which either an external clockevent device is used to send wakeup ipis
or the hrtimer broadcast framework kicks in in the absence of such a
device. One cpu is nominated as the broadcast cpu and this cpu sends
wakeup ipis to sleeping cpus at the appropriate time. This is the
implementation in the oneshot mode of broadcast.

In periodic mode of broadcast however, the presence of such cpuidle
states results in the cpuidle driver calling tick_broadcast_enable()
which shuts down the local clockevent devices of all the cpus and
appoints the tick broadcast device as the clockevent device for each of
them. This works on those archs where the tick broadcast device is a
real clockevent device. But on archs which depend on the hrtimer mode
of broadcast, the tick broadcast device hapens to be a pseudo device.
The consequence is that the local clockevent devices of all cpus are
shutdown and the kernel hangs at boot time in periodic mode.

Let us thus not register the cpuidle states which have
CPUIDLE_FLAG_TIMER_STOP flag set, on archs which depend on the hrtimer
mode of broadcast in periodic mode. This patch takes care of doing this
on powerpc. The cpus would not have entered into such deep cpuidle
states in periodic mode on powerpc anyway. So there is no loss here.

Signed-off-by: Preeti U Murthy <[email protected]>
---
drivers/cpuidle/cpuidle-powernv.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
index 5937207..3442764 100644
--- a/drivers/cpuidle/cpuidle-powernv.c
+++ b/drivers/cpuidle/cpuidle-powernv.c
@@ -60,6 +60,8 @@ static int nap_loop(struct cpuidle_device *dev,
return index;
}

+/* Register for fastsleep only in oneshot mode of broadcast */
+#ifdef CONFIG_TICK_ONESHOT
static int fastsleep_loop(struct cpuidle_device *dev,
struct cpuidle_driver *drv,
int index)
@@ -83,7 +85,7 @@ static int fastsleep_loop(struct cpuidle_device *dev,

return index;
}
-
+#endif
/*
* States for dedicated partition case.
*/
@@ -209,7 +211,14 @@ static int powernv_add_idle_states(void)
powernv_states[nr_idle_states].flags = 0;
powernv_states[nr_idle_states].target_residency = 100;
powernv_states[nr_idle_states].enter = &nap_loop;
- } else if (flags[i] & OPAL_PM_SLEEP_ENABLED ||
+ }
+
+ /*
+ * All cpuidle states with CPUIDLE_FLAG_TIMER_STOP set must come
+ * within this config dependency check.
+ */
+#ifdef CONFIG_TICK_ONESHOT
+ if (flags[i] & OPAL_PM_SLEEP_ENABLED ||
flags[i] & OPAL_PM_SLEEP_ENABLED_ER1) {
/* Add FASTSLEEP state */
strcpy(powernv_states[nr_idle_states].name, "FastSleep");
@@ -218,7 +227,7 @@ static int powernv_add_idle_states(void)
powernv_states[nr_idle_states].target_residency = 300000;
powernv_states[nr_idle_states].enter = &fastsleep_loop;
}
-
+#endif
powernv_states[nr_idle_states].exit_latency =
((unsigned int)latency_ns[i]) / 1000;


2015-06-24 13:24:40

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On Wednesday, June 24, 2015 01:48:01 AM Preeti U Murthy wrote:
> On some archs, the local clockevent device stops in deep cpuidle states.
> The broadcast framework is used to wakeup cpus in these idle states, in
> which either an external clockevent device is used to send wakeup ipis
> or the hrtimer broadcast framework kicks in in the absence of such a
> device. One cpu is nominated as the broadcast cpu and this cpu sends
> wakeup ipis to sleeping cpus at the appropriate time. This is the
> implementation in the oneshot mode of broadcast.
>
> In periodic mode of broadcast however, the presence of such cpuidle
> states results in the cpuidle driver calling tick_broadcast_enable()
> which shuts down the local clockevent devices of all the cpus and
> appoints the tick broadcast device as the clockevent device for each of
> them. This works on those archs where the tick broadcast device is a
> real clockevent device. But on archs which depend on the hrtimer mode
> of broadcast, the tick broadcast device hapens to be a pseudo device.
> The consequence is that the local clockevent devices of all cpus are
> shutdown and the kernel hangs at boot time in periodic mode.
>
> Let us thus not register the cpuidle states which have
> CPUIDLE_FLAG_TIMER_STOP flag set, on archs which depend on the hrtimer
> mode of broadcast in periodic mode. This patch takes care of doing this
> on powerpc. The cpus would not have entered into such deep cpuidle
> states in periodic mode on powerpc anyway. So there is no loss here.
>
> Signed-off-by: Preeti U Murthy <[email protected]>

4.2 material I suppose?

> ---
> drivers/cpuidle/cpuidle-powernv.c | 15 ++++++++++++---
> 1 file changed, 12 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpuidle/cpuidle-powernv.c b/drivers/cpuidle/cpuidle-powernv.c
> index 5937207..3442764 100644
> --- a/drivers/cpuidle/cpuidle-powernv.c
> +++ b/drivers/cpuidle/cpuidle-powernv.c
> @@ -60,6 +60,8 @@ static int nap_loop(struct cpuidle_device *dev,
> return index;
> }
>
> +/* Register for fastsleep only in oneshot mode of broadcast */
> +#ifdef CONFIG_TICK_ONESHOT
> static int fastsleep_loop(struct cpuidle_device *dev,
> struct cpuidle_driver *drv,
> int index)
> @@ -83,7 +85,7 @@ static int fastsleep_loop(struct cpuidle_device *dev,
>
> return index;
> }
> -
> +#endif
> /*
> * States for dedicated partition case.
> */
> @@ -209,7 +211,14 @@ static int powernv_add_idle_states(void)
> powernv_states[nr_idle_states].flags = 0;
> powernv_states[nr_idle_states].target_residency = 100;
> powernv_states[nr_idle_states].enter = &nap_loop;
> - } else if (flags[i] & OPAL_PM_SLEEP_ENABLED ||
> + }
> +
> + /*
> + * All cpuidle states with CPUIDLE_FLAG_TIMER_STOP set must come
> + * within this config dependency check.
> + */
> +#ifdef CONFIG_TICK_ONESHOT
> + if (flags[i] & OPAL_PM_SLEEP_ENABLED ||
> flags[i] & OPAL_PM_SLEEP_ENABLED_ER1) {
> /* Add FASTSLEEP state */
> strcpy(powernv_states[nr_idle_states].name, "FastSleep");
> @@ -218,7 +227,7 @@ static int powernv_add_idle_states(void)
> powernv_states[nr_idle_states].target_residency = 300000;
> powernv_states[nr_idle_states].enter = &fastsleep_loop;
> }
> -
> +#endif
> powernv_states[nr_idle_states].exit_latency =
> ((unsigned int)latency_ns[i]) / 1000;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.

2015-06-24 23:47:10

by Benjamin Herrenschmidt

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On Wed, 2015-06-24 at 15:50 +0200, Rafael J. Wysocki wrote:
> 4.2 material I suppose?

And stable. Without this, if you configure without TICK_ONESHOT, the
machine will hang.

Cheers,
Ben.

2015-06-24 22:10:49

by Michael Ellerman

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode



On 24 June 2015 23:50:40 GMT+10:00, "Rafael J. Wysocki" <[email protected]> wrote:
>On Wednesday, June 24, 2015 01:48:01 AM Preeti U Murthy wrote:
>> On some archs, the local clockevent device stops in deep cpuidle
>states.
>> The broadcast framework is used to wakeup cpus in these idle states,
>in
>> which either an external clockevent device is used to send wakeup
>ipis
>> or the hrtimer broadcast framework kicks in in the absence of such a
>> device. One cpu is nominated as the broadcast cpu and this cpu sends
>> wakeup ipis to sleeping cpus at the appropriate time. This is the
>> implementation in the oneshot mode of broadcast.
>>
>> In periodic mode of broadcast however, the presence of such cpuidle
>> states results in the cpuidle driver calling tick_broadcast_enable()
>> which shuts down the local clockevent devices of all the cpus and
>> appoints the tick broadcast device as the clockevent device for each
>of
>> them. This works on those archs where the tick broadcast device is a
>> real clockevent device. But on archs which depend on the hrtimer
>mode
>> of broadcast, the tick broadcast device hapens to be a pseudo device.
>> The consequence is that the local clockevent devices of all cpus are
>> shutdown and the kernel hangs at boot time in periodic mode.
>>
>> Let us thus not register the cpuidle states which have
>> CPUIDLE_FLAG_TIMER_STOP flag set, on archs which depend on the
>hrtimer
>> mode of broadcast in periodic mode. This patch takes care of doing
>this
>> on powerpc. The cpus would not have entered into such deep cpuidle
>> states in periodic mode on powerpc anyway. So there is no loss here.
>>
>> Signed-off-by: Preeti U Murthy <[email protected]>
>
>4.2 material I suppose?

Yes please, in fact it should be marked for stable too.

cheers
--
Sent from my Android phone with K-9 Mail. Please excuse my brevity.

2015-06-24 22:28:29

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On Thu, Jun 25, 2015 at 12:10 AM, Michael Ellerman
<[email protected]> wrote:
>
>
> On 24 June 2015 23:50:40 GMT+10:00, "Rafael J. Wysocki" <[email protected]> wrote:
>>On Wednesday, June 24, 2015 01:48:01 AM Preeti U Murthy wrote:
>>> On some archs, the local clockevent device stops in deep cpuidle
>>states.
>>> The broadcast framework is used to wakeup cpus in these idle states,
>>in
>>> which either an external clockevent device is used to send wakeup
>>ipis
>>> or the hrtimer broadcast framework kicks in in the absence of such a
>>> device. One cpu is nominated as the broadcast cpu and this cpu sends
>>> wakeup ipis to sleeping cpus at the appropriate time. This is the
>>> implementation in the oneshot mode of broadcast.
>>>
>>> In periodic mode of broadcast however, the presence of such cpuidle
>>> states results in the cpuidle driver calling tick_broadcast_enable()
>>> which shuts down the local clockevent devices of all the cpus and
>>> appoints the tick broadcast device as the clockevent device for each
>>of
>>> them. This works on those archs where the tick broadcast device is a
>>> real clockevent device. But on archs which depend on the hrtimer
>>mode
>>> of broadcast, the tick broadcast device hapens to be a pseudo device.
>>> The consequence is that the local clockevent devices of all cpus are
>>> shutdown and the kernel hangs at boot time in periodic mode.
>>>
>>> Let us thus not register the cpuidle states which have
>>> CPUIDLE_FLAG_TIMER_STOP flag set, on archs which depend on the
>>hrtimer
>>> mode of broadcast in periodic mode. This patch takes care of doing
>>this
>>> on powerpc. The cpus would not have entered into such deep cpuidle
>>> states in periodic mode on powerpc anyway. So there is no loss here.
>>>
>>> Signed-off-by: Preeti U Murthy <[email protected]>
>>
>>4.2 material I suppose?
>
> Yes please, in fact it should be marked for stable too.

That can be done. Which -stable series should it go into?

Rafael

2015-06-25 00:06:43

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On Thu, Jun 25, 2015 at 12:06 AM, Benjamin Herrenschmidt
<[email protected]> wrote:
> On Wed, 2015-06-24 at 15:50 +0200, Rafael J. Wysocki wrote:
>> 4.2 material I suppose?
>
> And stable. Without this, if you configure without TICK_ONESHOT, the
> machine will hang.

OK, which -stable? All of them or any specific series?

Rafael

2015-06-25 03:36:16

by Preeti U Murthy

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On 06/25/2015 05:36 AM, Rafael J. Wysocki wrote:
> On Thu, Jun 25, 2015 at 12:06 AM, Benjamin Herrenschmidt
> <[email protected]> wrote:
>> On Wed, 2015-06-24 at 15:50 +0200, Rafael J. Wysocki wrote:
>>> 4.2 material I suppose?
>>
>> And stable. Without this, if you configure without TICK_ONESHOT, the
>> machine will hang.
>
> OK, which -stable? All of them or any specific series?

This needs to go into stable/linux-3.19.y,
stable/linux-4.0.y, stable/linux-4.1.y.

Thanks

Regards
Preeti U Murthy
>
> Rafael
> _______________________________________________
> Linuxppc-dev mailing list
> [email protected]
> https://lists.ozlabs.org/listinfo/linuxppc-dev
>

2015-06-26 13:57:55

by Rafael J. Wysocki

[permalink] [raw]
Subject: Re: [PATCH] tick/idle/powerpc: Do not register idle states with CPUIDLE_FLAG_TIMER_STOP set in periodic mode

On Thursday, June 25, 2015 09:05:49 AM Preeti U Murthy wrote:
> On 06/25/2015 05:36 AM, Rafael J. Wysocki wrote:
> > On Thu, Jun 25, 2015 at 12:06 AM, Benjamin Herrenschmidt
> > <[email protected]> wrote:
> >> On Wed, 2015-06-24 at 15:50 +0200, Rafael J. Wysocki wrote:
> >>> 4.2 material I suppose?
> >>
> >> And stable. Without this, if you configure without TICK_ONESHOT, the
> >> machine will hang.
> >
> > OK, which -stable? All of them or any specific series?
>
> This needs to go into stable/linux-3.19.y,
> stable/linux-4.0.y, stable/linux-4.1.y.

So essentially 3.19+. OK, thanks!


--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.