Skip to contentSkip to conversation

FAILED: patch "[PATCH] sched/idle/x86: Restore mwait_idle() to fix boot hangs, to" failed to apply to 3.14-stable tree

PATCH [email protected] 3 participants 4 messages Apr 29, 2015 – May 5, 2015

Subsystems (2)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 3.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

Quoted 1 line

From b253149b843f89cd300cbdbea27ce1f847506f99 Mon Sep 17 00:00:00 2001

From: Len Brown <[email protected]>
Date: Wed, 15 Jan 2014 00:37:34 -0500
Subject: [PATCH] sched/idle/x86: Restore mwait_idle() to fix boot hangs, to
improve power savings and to improve performance

In Linux-3.9 we removed the mwait_idle() loop:

69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param")

The reasoning was that modern machines should be sufficiently happy during the boot process using the default_idle() HALT loop, until cpuidle loads and either acpi_idle or intel_idle invoke the newer MWAIT-with-hints idle loop.

But two machines reported problems:

1. Certain Core2-era machines support MWAIT-C1 and HALT only. MWAIT-C1 is preferred for optimal power and performance. But if they support just C1, cpuidle never loads and so they use the boot-time default idle loop forever.

2. Some laptops will boot-hang if HALT is used, but will boot successfully if MWAIT is used. This appears to be a hidden assumption in BIOS SMI, that is presumably valid on the proprietary OS where the BIOS was validated.

https://bugzilla.kernel.org/show_bug.cgi?id=60770

So here we effectively revert the patch above, restoring the mwait_idle() loop. However, we don't bother restoring the idle=mwait cmdline parameter, since it appears to add no value.

Maintainer notes:

For 3.9, simply revert 69fb3676df
for 3.10, patch -F3 applies, fuzz needed due to __cpuinit use in context For 3.11, 3.12, 3.13, this patch applies cleanly

arch/x86/include/asm/mwait.h +8 -0
index a1410db38a1a..653dfa7662e1 100644
@@ -30,6 +30,14 @@ static inline void __mwait(unsigned long eax, unsigned long ecx)
 		     :: "a" (eax), "c" (ecx));
 }
 
+static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
+{
+	trace_hardirqs_on();
+	/* "mwait %eax, %ecx;" */
+	asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
+		     :: "a" (eax), "c" (ecx));
+}
+
 /*
  * This uses new MONITOR/MWAIT instructions on P4 processors with PNI,
  * which can obviate IPI to trigger checking of need_resched.
arch/x86/kernel/process.c +47 -0

65 lines not on this page · raw message

Tested-by Acked-by
#1 lore raw
Quoted 6 lines · On Wed, 2015-04-29 at 16:13 +0200, [email protected] wrote:

The patch below does not apply to the 3.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

From b253149b843f89cd300cbdbea27ce1f847506f99 Mon Sep 17 00:00:00 2001

From: Len Brown <[email protected]>
Date: Wed, 15 Jan 2014 00:37:34 -0500
Subject: sched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance

In Linux-3.9 we removed the mwait_idle() loop:

69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param")

The reasoning was that modern machines should be sufficiently happy during the boot process using the default_idle() HALT loop, until cpuidle loads and either acpi_idle or intel_idle invoke the newer MWAIT-with-hints idle loop.

But two machines reported problems:

1. Certain Core2-era machines support MWAIT-C1 and HALT only. MWAIT-C1 is preferred for optimal power and performance. But if they support just C1, cpuidle never loads and so they use the boot-time default idle loop forever.

2. Some laptops will boot-hang if HALT is used, but will boot successfully if MWAIT is used. This appears to be a hidden assumption in BIOS SMI, that is presumably valid on the proprietary OS where the BIOS was validated.

https://bugzilla.kernel.org/show_bug.cgi?id=60770

So here we effectively revert the patch above, restoring the mwait_idle() loop. However, we don't bother restoring the idle=mwait cmdline parameter, since it appears to add no value.

Maintainer notes:

For 3.9, simply revert 69fb3676df
for 3.10, patch -F3 applies, fuzz needed due to __cpuinit use in context For 3.11, 3.12, 3.13, this patch applies cleanly

---
 arch/x86/include/asm/mwait.h |    8 ++++++
 arch/x86/kernel/process.c    |   50 +++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+)
arch/x86/include/asm/mwait.h +8 -0
@@ -30,6 +30,14 @@ static inline void __mwait(unsigned long
 		     :: "a" (eax), "c" (ecx));
 }
 
+static inline void __sti_mwait(unsigned long eax, unsigned long ecx)
+{
+	trace_hardirqs_on();
+	/* "mwait %eax, %ecx;" */
+	asm volatile("sti; .byte 0x0f, 0x01, 0xc9;"
+		     :: "a" (eax), "c" (ecx));
+}
+
 /*
  * This uses new MONITOR/MWAIT instructions on P4 processors with PNI,
  * which can obviate IPI to trigger checking of need_resched.
arch/x86/kernel/process.c +50 -0

68 lines not on this page · raw message

author maintainer
#2 lore raw
Quoted 6 lines · Mike Galbraith
Quoted 4 lines · On Wed, 2015-04-29 at 16:13 +0200, [email protected] wrote:

The patch below does not apply to the 3.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

Quoted 8 lines
Quoted 1 line

From b253149b843f89cd300cbdbea27ce1f847506f99 Mon Sep 17 00:00:00 2001

From: Len Brown <[email protected]>
Date: Wed, 15 Jan 2014 00:37:34 -0500
Subject: sched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance

In Linux-3.9 we removed the mwait_idle() loop:

69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param")

Thanks, now applied.

greg k-h

#3 lore raw
In reply to Mike Galbraith
Quoted 15 lines · Mike Galbraith
Quoted 4 lines · On Wed, 2015-04-29 at 16:13 +0200, [email protected] wrote:

The patch below does not apply to the 3.14-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

From b253149b843f89cd300cbdbea27ce1f847506f99 Mon Sep 17 00:00:00 2001
From: Len Brown <[email protected]>
Date: Wed, 15 Jan 2014 00:37:34 -0500
Subject: sched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance

In Linux-3.9 we removed the mwait_idle() loop:

69fb3676df33 ("x86 idle: remove mwait_idle() and "idle=mwait" cmdline param")

[...]

Quoted 2 lines

[ Ported to recent kernels. ]
[ Mike: 3.10 backport ]

Thanks! I'll use this backport for the 3.16 kernel as well.

Cheers,
--
Lu�s