Skip to contentSkip to conversation

next-20120313 cpuidle freezes when booting

PATCH In review Hugh Dickins 5 participants 12 messages Mar 13, 2012 – Mar 20, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

Hi Stephen,

Yesterday's 3.3.0-rc7-next-20120313 gives me unpredictable freezes on x86_64, on a ThinkPad T420s - I've not dared it on more machines.

Usually when booting up (sometimes just after Freeing unused kernel memory, sometimes random places elsewhere), but occasionally it manages to get as far as X; doesn't usually manage to complete suspend+resume.

3.3.0-rc6-nex-20120309 behaved similarly; the last I tried before that was 3.3.0-rc5-next20120227, which was okay.

Bisection led me to "cpuidle: Add common time keeping and irq enabling", (from the cpuidle-cons tree I think), and reverting that has so far given me a working system (it's a success if I complete this mail).

Below is the patch I've used to revert it (for other people having problems with recent linux-next to try); but it's not quite correct, because you did a merge on conflicting trees there, and I didn't spend time to unravel all that, just get a working x86 system - since I've left out some of your merge (in arch/arm/kernel/Makefile and arch/arm/ mach-at91/cpuidle.c), this reversion probably breaks arm as is.

Hugh

arch/arm/include/asm/cpuidle.h +0 -22
@@ -1,22 +0,0 @@
-#ifndef __ASM_ARM_CPUIDLE_H
-#define __ASM_ARM_CPUIDLE_H
-
-#ifdef CONFIG_CPU_IDLE
-extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index);
-#else
-static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index) { return -ENODEV; }
-#endif
-
-/* Common ARM WFI state */
-#define ARM_CPUIDLE_WFI_STATE {\
-	.enter                  = arm_cpuidle_simple_enter,\
-	.exit_latency           = 1,\
-	.target_residency       = 1,\
-	.flags                  = CPUIDLE_FLAG_TIME_VALID,\
-	.name                   = "WFI",\
-	.desc                   = "ARM WFI",\
-}
-
-#endif
arch/arm/kernel/Makefile +1 -1
@@ -23,7 +23,7 @@ obj-$(CONFIG_DEPRECATED_PARAM_STRUCT) +=
 
 obj-$(CONFIG_LEDS)		+= leds.o
 obj-$(CONFIG_OC_ETM)		+= etm.o
-obj-$(CONFIG_CPU_IDLE)		+= cpuidle.o
+
 obj-$(CONFIG_ISA_DMA_API)	+= dma.o
 obj-$(CONFIG_FIQ)		+= fiq.o fiqasm.o
 obj-$(CONFIG_MODULES)		+= armksyms.o module.o
arch/arm/kernel/cpuidle.c +0 -21
@@ -1,21 +0,0 @@
-/*
- * Copyright 2012 Linaro Ltd.
- *
- * The code contained herein is licensed under the GNU General Public
- * License. You may obtain a copy of the GNU General Public License
- * Version 2 or later at the following locations:
- *
- * http://www.opensource.org/licenses/gpl-license.html
- * http://www.gnu.org/copyleft/gpl.html
- */
-
-#include <linux/cpuidle.h>
-#include <asm/proc-fns.h>
-
-int arm_cpuidle_simple_enter(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index)
-{
-	cpu_do_idle();
-
-	return index;
-}
drivers/cpuidle/cpuidle.c +16 -63

143 lines not on this page · raw message

include/linux/cpuidle.h +1 -12
@@ -15,7 +15,6 @@
 #include <linux/list.h>
 #include <linux/kobject.h>
 #include <linux/completion.h>
-#include <linux/hrtimer.h>
 
 #define CPUIDLE_STATE_MAX	8
 #define CPUIDLE_NAME_LEN	16
@@ -124,8 +123,6 @@ struct cpuidle_driver {
 	struct module 		*owner;
 
 	unsigned int		power_specified:1;
-	/* set to 1 to use the core cpuidle time keeping (for all states). */
-	unsigned int		en_core_tk_irqen:1;
 	struct cpuidle_state	states[CPUIDLE_STATE_MAX];
 	int			state_count;
 	int			safe_state_index;
@@ -144,10 +141,7 @@ extern void cpuidle_pause_and_lock(void)
 extern void cpuidle_resume_and_unlock(void);
 extern int cpuidle_enable_device(struct cpuidle_device *dev);
 extern void cpuidle_disable_device(struct cpuidle_device *dev);
-extern int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index));
+
 #else
 static inline void disable_cpuidle(void) { }
 static inline int cpuidle_idle_call(void) { return -ENODEV; }
@@ -164,11 +158,6 @@ static inline void cpuidle_resume_and_un
 static inline int cpuidle_enable_device(struct cpuidle_device *dev)
 {return -ENODEV; }
 static inline void cpuidle_disable_device(struct cpuidle_device *dev) { }
-static inline int cpuidle_wrap_enter(struct cpuidle_device *dev,
-				struct cpuidle_driver *drv, int index,
-				int (*enter)(struct cpuidle_device *dev,
-					struct cpuidle_driver *drv, int index))
-{ return -ENODEV; }
 
 #endif
 
#1 lore raw
Quoted 16 lines · Hugh Dickins

Hi Stephen,

Yesterday's 3.3.0-rc7-next-20120313 gives me unpredictable freezes on x86_64, on a ThinkPad T420s - I've not dared it on more machines.

Usually when booting up (sometimes just after Freeing unused kernel memory, sometimes random places elsewhere), but occasionally it manages to get as far as X; doesn't usually manage to complete suspend+resume.

3.3.0-rc6-nex-20120309 behaved similarly; the last I tried before that was 3.3.0-rc5-next20120227, which was okay.

Bisection led me to "cpuidle: Add common time keeping and irq enabling", (from the cpuidle-cons tree I think), and reverting that has so far given me a working system (it's a success if I complete this mail).

Quoted 6 lines

Below is the patch I've used to revert it (for other people having problems with recent linux-next to try); but it's not quite correct, because you did a merge on conflicting trees there, and I didn't spend time to unravel all that, just get a working x86 system - since I've left out some of your merge (in arch/arm/kernel/Makefile and arch/arm/ mach-at91/cpuidle.c), this reversion probably breaks arm as is.

Hi Hugh,

is it possible you give the cpuidle driver your host is using ?

Thanks
-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#2 lore raw
Quoted 24 lines · Daniel Lezcano
Quoted 16 lines · Hugh Dickins

Hi Stephen,

Yesterday's 3.3.0-rc7-next-20120313 gives me unpredictable freezes on x86_64, on a ThinkPad T420s - I've not dared it on more machines.

Usually when booting up (sometimes just after Freeing unused kernel memory, sometimes random places elsewhere), but occasionally it manages to get as far as X; doesn't usually manage to complete suspend+resume.

3.3.0-rc6-nex-20120309 behaved similarly; the last I tried before that was 3.3.0-rc5-next20120227, which was okay.

Bisection led me to "cpuidle: Add common time keeping and irq enabling", (from the cpuidle-cons tree I think), and reverting that has so far given me a working system (it's a success if I complete this mail).

Quoted 6 lines

Below is the patch I've used to revert it (for other people having problems with recent linux-next to try); but it's not quite correct, because you did a merge on conflicting trees there, and I didn't spend time to unravel all that, just get a working x86 system - since I've left out some of your merge (in arch/arm/kernel/Makefile and arch/arm/ mach-at91/cpuidle.c), this reversion probably breaks arm as is.

Quoted 3 lines

Hi Hugh,

is it possible you give the cpuidle driver your host is using ?

"grep IDLE .config" tells me:

CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
CONFIG_ARCH_HAS_DEFAULT_IDLE=y
CONFIG_CPU_IDLE=y
CONFIG_CPU_IDLE_GOV_LADDER=y
CONFIG_CPU_IDLE_GOV_MENU=y
CONFIG_INTEL_IDLE=y
# CONFIG_I7300_IDLE is not set

but I've a feeling that isn't what you need to know.

Is there some /proc or /sys file I can read to tell you?

Though if it's something that changes dynamically, then what I read now might not be what it would say when things go wrong.

I expect you've realized by now, I haven't a clue about cpuidle
drivers: I hadn't even realized that idleness needs a driver.

Hugh

#3 lore raw
Quoted 39 lines · Hugh Dickins
Quoted 24 lines · Daniel Lezcano
Quoted 16 lines · Hugh Dickins

Hi Stephen,

Yesterday's 3.3.0-rc7-next-20120313 gives me unpredictable freezes on x86_64, on a ThinkPad T420s - I've not dared it on more machines.

Usually when booting up (sometimes just after Freeing unused kernel memory, sometimes random places elsewhere), but occasionally it manages to get as far as X; doesn't usually manage to complete suspend+resume.

3.3.0-rc6-nex-20120309 behaved similarly; the last I tried before that was 3.3.0-rc5-next20120227, which was okay.

Bisection led me to "cpuidle: Add common time keeping and irq enabling", (from the cpuidle-cons tree I think), and reverting that has so far given me a working system (it's a success if I complete this mail).

Quoted 6 lines

Below is the patch I've used to revert it (for other people having problems with recent linux-next to try); but it's not quite correct, because you did a merge on conflicting trees there, and I didn't spend time to unravel all that, just get a working x86 system - since I've left out some of your merge (in arch/arm/kernel/Makefile and arch/arm/ mach-at91/cpuidle.c), this reversion probably breaks arm as is.

Quoted 3 lines

Hi Hugh,

is it possible you give the cpuidle driver your host is using ?

"grep IDLE .config" tells me:

CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
CONFIG_ARCH_HAS_DEFAULT_IDLE=y
CONFIG_CPU_IDLE=y
CONFIG_CPU_IDLE_GOV_LADDER=y
CONFIG_CPU_IDLE_GOV_MENU=y
CONFIG_INTEL_IDLE=y
# CONFIG_I7300_IDLE is not set

Quoted 1 line

but I've a feeling that isn't what you need to know.

Thanks for these informations, I forgot to ask you for them. By the way, do you have CONFIG_ARCH_HAS_CPU_RELAX ?

Quoted 1 line

Is there some /proc or /sys file I can read to tell you?

Yes, the content of /sys/devices/system/cpu/cpuidle/current_driver and /sys/devices/system/cpu/cpuidle/current_governor_ro

Quoted 2 lines

Though if it's something that changes dynamically, then what I read now might not be what it would say when things go wrong.

No, that won't change, so the information should be enough for me to find the code path where the regression is.

Quoted 2 lines

I expect you've realized by now, I haven't a clue about cpuidle
drivers: I hadn't even realized that idleness needs a driver.

No problem, thanks for git bisecting and find the culprit :)

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
#4 lore raw
Quoted 19 lines · Daniel Lezcano
Quoted 18 lines · Hugh Dickins
Quoted 6 lines · Daniel Lezcano
Quoted 3 lines · Hugh Dickins

Yesterday's 3.3.0-rc7-next-20120313 gives me unpredictable freezes on x86_64, on a ThinkPad T420s - I've not dared it on more machines.

is it possible you give the cpuidle driver your host is using ?

"grep IDLE .config" tells me:

CONFIG_ARCH_HAS_CPU_IDLE_WAIT=y
CONFIG_ARCH_HAS_DEFAULT_IDLE=y
CONFIG_CPU_IDLE=y
CONFIG_CPU_IDLE_GOV_LADDER=y
CONFIG_CPU_IDLE_GOV_MENU=y
CONFIG_INTEL_IDLE=y
# CONFIG_I7300_IDLE is not set

Quoted 4 lines
Quoted 1 line

but I've a feeling that isn't what you need to know.

Thanks for these informations, I forgot to ask you for them. By the way, do you have CONFIG_ARCH_HAS_CPU_RELAX ?

Yes.

Quoted 4 lines
Quoted 2 lines

Is there some /proc or /sys file I can read to tell you?

Yes, the content of /sys/devices/system/cpu/cpuidle/current_driver

intel_idle

Quoted 1 line

and /sys/devices/system/cpu/cpuidle/current_governor_ro

menu

Quoted 11 lines
Quoted 3 lines

Though if it's something that changes dynamically, then what I read now might not be what it would say when things go wrong.

No, that won't change, so the information should be enough for me to find the code path where the regression is.

Quoted 2 lines

I expect you've realized by now, I haven't a clue about cpuidle
drivers: I hadn't even realized that idleness needs a driver.

No problem, thanks for git bisecting and find the culprit :)

Thank you - let me know if you've something you'd like me to try.

Hugh

#5 lore raw

PATCH 1/1 cpuidle : fix random hangs with intel_idle

In reply to Hugh Dickins

The cpuidle consolidation inverts the local_irq_enable for the poll_idle function with CPU_RELAX.

---
 drivers/cpuidle/cpuidle.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)
drivers/cpuidle/cpuidle.c +13 -8
index 56de5f7..4869b55 100644
@@ -213,20 +213,25 @@ int cpuidle_wrap_enter(struct cpuidle_device *dev,
 }
 
 #ifdef CONFIG_ARCH_HAS_CPU_RELAX
-static inline int __poll_idle(struct cpuidle_device *dev,
+static int poll_idle(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int index)
 {
+	ktime_t	t1, t2;
+	s64 diff;
+
+	t1 = ktime_get();
+	local_irq_enable();
 	while (!need_resched())
 		cpu_relax();
 
-	return index;
-}
+	t2 = ktime_get();
+	diff = ktime_to_us(ktime_sub(t2, t1));
+	if (diff > INT_MAX)
+		diff = INT_MAX;
 
-static int poll_idle(struct cpuidle_device *dev,
-		struct cpuidle_driver *drv, int index)
-{
-	return cpuidle_wrap_enter(dev,	drv, index,
-				__poll_idle);
+	dev->last_residency = (int) diff;
+
+	return index;
 }
 
 static void poll_idle_init(struct cpuidle_driver *drv)
Signature · 1 line
1.7.5.4
#6 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Hi Daniel,

Quoted 6 lines · On Thu, 15 Mar 2012 01:09:41 +0100 Daniel Lezcano <[email protected]>…

The cpuidle consolidation inverts the local_irq_enable for the poll_idle function with CPU_RELAX.

So this needs to go into Rob's tree. Maybe after Hugh verifies that it fixes his problem.

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
author Tested-by
#7 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Quoted 10 lines · Stephen Rothwell
Quoted 6 lines · On Thu, 15 Mar 2012 01:09:41 +0100 Daniel Lezcano <[email protected]>…

The cpuidle consolidation inverts the local_irq_enable for the poll_idle function with CPU_RELAX.

So this needs to go into Rob's tree. Maybe after Hugh verifies that it fixes his problem.

Yes, Daniel got me to try it offline before he posted it.

Personally, I'd recommend including it even before it gets into Rob's tree (where it may well be improved upon first): it does a lot to improve the usability of linux-next.

Hugh

#8 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Hi Hugh,

Quoted 9 lines · On Wed, 14 Mar 2012 17:23:26 -0700 (PDT) Hugh Dickins <[email protected]> wrote:
Quoted 3 lines · Stephen Rothwell

So this needs to go into Rob's tree. Maybe after Hugh verifies that it fixes his problem.

Yes, Daniel got me to try it offline before he posted it.

Excellent.

Quoted 3 lines

Personally, I'd recommend including it even before it gets into Rob's tree (where it may well be improved upon first): it does a lot to improve the usability of linux-next.

OK, so I will add this patch to today's tree (on the assumption that it, or something better, will be added to Rob's tree soon).

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
#9 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Quoted 13 lines · Stephen Rothwell

Hi Hugh,

Quoted 9 lines · On Wed, 14 Mar 2012 17:23:26 -0700 (PDT) Hugh Dickins <[email protected]> wrote:
Quoted 3 lines · Stephen Rothwell

So this needs to go into Rob's tree.  Maybe after Hugh verifies that it fixes his problem.

Yes, Daniel got me to try it offline before he posted it.

Quoted 8 lines

Excellent.

Quoted 3 lines

Personally, I'd recommend including it even before it gets into Rob's tree (where it may well be improved upon first): it does a lot to improve the usability of linux-next.

OK, so I will add this patch to today's tree (on the assumption that it, or something better, will be added to Rob's tree soon).

Stephen,

A slight glitch: Rob is away until Tuesday. Should Daniel create a new branch to carry this?

/Amit

#10 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Hi Amit,

Quoted 3 lines · On Fri, 16 Mar 2012 15:37:07 +0200 Amit Kucheria <[email protected]>…

A slight glitch: Rob is away until Tuesday. Should Daniel create a new branch to carry this?

I can keep applying it to linux-next, it just needs to be added to Rob's tree before Linus is asked to merge it.

Signature · 2 lines
Cheers,
Stephen Rothwell                    [email protected]
#11 lore raw

Re: [PATCH] cpuidle : fix random hangs with intel_idle

Hello Stephen,

I am back in town and have reviewed and applied Daniel's fix to my tree. Also, I updated my tree to v3.3.

git://git.linaro.org/people/rob_lee/linux.git cpuidle_consol_pull

Daniel, thank you for investigating and providing the fix in my absence.

Best Regards,
Rob

Quoted 13 lines · Stephen Rothwell

Hi Amit,

Quoted 3 lines · On Fri, 16 Mar 2012 15:37:07 +0200 Amit Kucheria <[email protected]>…

A slight glitch: Rob is away until Tuesday. Should Daniel create a new branch to carry this?

I can keep applying it to linux-next, it just needs to be added to Rob's tree before Linus is asked to merge it.

--
Cheers,
Stephen Rothwell                    [email protected]