x86 idle: restore mwait_idle()
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): 1ae2a8af42281d6b9888ac8c76bab7bd2f431d44.1389763084.git.len.brown@intel.com
PATCH 1/1 x86 idle: restore mwait_idle()
From: Len Brown <[email protected]>
In Linux-3.9 we removed the mwait_idle() loop:
'x86 idle: remove mwait_idle() and "idle=mwait" cmdline param' (69fb3676df3329a7142803bb3502fa59dc0db2e3)
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/kernel/process.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)
arch/x86/kernel/process.c +46 -0
@@ -398,6 +398,49 @@ static void amd_e400_idle(void)default_idle (); } +/* +* Intel Core2 and older machines prefer MWAIT over HALT for C1. +* We can't rely on cpuidle installing MWAIT, because it will not load +* on systems that support only C1 -- so the boot default must be MWAIT. +* +* Some AMD machines are the opposite, they depend on using HALT. +* +* So for default C1, which is used during boot until cpuidle loads, +* use MWAIT-C1 on Intel HW that has it, else use HALT. +*/ +static int prefer_mwait_c1_over_halt (const struct cpuinfo_x86 *c) +{ +if (c->x86_vendor !=X86_VENDOR_INTEL ) +return 0 ; + +if (!cpu_has (c,X86_FEATURE_MWAIT )) +return 0 ; + +return 1 ; +} + +/* +* MONITOR/MWAIT with no hints, used for default default C1 state. +* This invokes MWAIT with interrutps enabled and no flags, +* which is backwards compatible with the original MWAIT implementation. +*/ + +static void mwait_idle (void ) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags); + +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__sti_mwait (0 ,0 ); +else +local_irq_enable (); + }else +local_irq_enable (); +} +void select_idle_routine (const struct cpuinfo_x86 *c) {#ifdef CONFIG_SMP
@@ -411,6 +454,9 @@ void select_idle_routine(const struct cpuinfo_x86 *c)/* E400: APIC timer interrupt does not wake up CPU from C1e */ pr_info ("using AMD E400 aware idle routine\n" ); x86_idle = amd_e400_idle; + }else if (prefer_mwait_c1_over_halt (c)) { +pr_info ("using mwait in idle threads\n" ); + x86_idle = mwait_idle; }else x86_idle = default_idle; }
Signature · 1 line
1.8.5.2.309.ga25014b
Quoted 11 lines · Len Brown
From: Len Brown <[email protected]>
In Linux-3.9 we removed the
mwait_idle()loop:
'x86 idle: removemwait_idle()and "idle=mwait" cmdline param' (69fb3676df3329a7142803bb3502fa59dc0db2e3)The reasoning was that modern machines should be sufficiently happy during the boot process using the
default_idle()HALT loop, until cpuidle loads and eitheracpi_idleorintel_idleinvoke the newer MWAIT-with-hints idle loop.
Quoted 5 lines
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.
Q6600 box (allegedly) has a slightly greenish tinge again.
Quoted 91 lines
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=60770So 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 revert69fb3676df
for 3.10, patch -F3 applies, fuzz needed due to__cpuinituse in context For 3.11, 3.12, 3.13, this patch applies cleanlyCc Mike Galbraith <[email protected]>Cc Ian Malone <[email protected]>Cc Josh Boyer <[email protected]>Cc <[email protected]> # 3.9, 3.10, 3.11, 3.12, 3.13Signed-off-by Len Brown <[email protected]>--- arch/x86/kernel/process.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)arch/x86/kernel/process.c +46
-0@@ -398,6 +398,49 @@ static void amd_e400_idle(void)default_idle (); } +/* +* Intel Core2 and older machines prefer MWAIT over HALT for C1. +* We can't rely on cpuidle installing MWAIT, because it will not load +* on systems that support only C1 -- so the boot default must be MWAIT. +* +* Some AMD machines are the opposite, they depend on using HALT. +* +* So for default C1, which is used during boot until cpuidle loads, +* use MWAIT-C1 on Intel HW that has it, else use HALT. +*/ +static int prefer_mwait_c1_over_halt (const struct cpuinfo_x86 *c) +{ +if (c->x86_vendor !=X86_VENDOR_INTEL ) +return 0 ; + +if (!cpu_has (c,X86_FEATURE_MWAIT )) +return 0 ; + +return 1 ; +} + +/* +* MONITOR/MWAIT with no hints, used for default default C1 state. +* This invokes MWAIT with interrutps enabled and no flags, +* which is backwards compatible with the original MWAIT implementation. +*/ + +static void mwait_idle (void ) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags); + +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__sti_mwait (0 ,0 ); +else +local_irq_enable (); + }else +local_irq_enable (); +} +void select_idle_routine (const struct cpuinfo_x86 *c) {#ifdef CONFIG_SMP @@ -411,6 +454,9 @@ void select_idle_routine(const struct cpuinfo_x86 *c)/* E400: APIC timer interrupt does not wake up CPU from C1e */ pr_info ("using AMD E400 aware idle routine\n" ); x86_idle = amd_e400_idle; + }else if (prefer_mwait_c1_over_halt (c)) { +pr_info ("using mwait in idle threads\n" ); + x86_idle = mwait_idle; }else x86_idle = default_idle; }
Quoted 84 lines · Len Brown
From: Len Brown <[email protected]>
In Linux-3.9 we removed the
mwait_idle()loop:
'x86 idle: removemwait_idle()and "idle=mwait" cmdline param' (69fb3676df3329a7142803bb3502fa59dc0db2e3)The reasoning was that modern machines should be sufficiently happy during the boot process using the
default_idle()HALT loop, until cpuidle loads and eitheracpi_idleorintel_idleinvoke 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=60770So 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 revert69fb3676df
for 3.10, patch -F3 applies, fuzz needed due to__cpuinituse in context For 3.11, 3.12, 3.13, this patch applies cleanlyCc Mike Galbraith <[email protected]>Cc Ian Malone <[email protected]>Cc Josh Boyer <[email protected]>Cc <[email protected]> # 3.9, 3.10, 3.11, 3.12, 3.13Signed-off-by Len Brown <[email protected]>--- arch/x86/kernel/process.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)arch/x86/kernel/process.c +32
-0@@ -398,6 +398,49 @@ static void amd_e400_idle(void)default_idle (); } +/* +* Intel Core2 and older machines prefer MWAIT over HALT for C1. +* We can't rely on cpuidle installing MWAIT, because it will not load +* on systems that support only C1 -- so the boot default must be MWAIT. +* +* Some AMD machines are the opposite, they depend on using HALT. +* +* So for default C1, which is used during boot until cpuidle loads, +* use MWAIT-C1 on Intel HW that has it, else use HALT. +*/ +static int prefer_mwait_c1_over_halt (const struct cpuinfo_x86 *c) +{ +if (c->x86_vendor !=X86_VENDOR_INTEL ) +return 0 ; + +if (!cpu_has (c,X86_FEATURE_MWAIT )) +return 0 ; + +return 1 ; +} + +/* +* MONITOR/MWAIT with no hints, used for default default C1 state. +* This invokes MWAIT with interrutps enabled and no flags, +* which is backwards compatible with the original MWAIT implementation. +*/ + +static void mwait_idle (void ) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags);
arch/x86/kernel/process.c static void amd_e400_idle(void) · line 442
Quoted 10 lines
arch/x86/kernel/process.c +10
-0+ +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__sti_mwait (0 ,0 ); +else +local_irq_enable (); + }else +local_irq_enable (); +}
Admittedly, there may be relatively few users left, but SMP users on C1-only Core 2 machines can, in principle, benefit from the monitor functionality of mwait to avoid rescheduling IPIs. This stuff changed recently so it now works with the cpuidle drivers (it used to be terminally broken). Should something be twiddling TS_POLLING differently so that HLT gets the IPIs but mwait doesn't?
--Andy
Quoted 15 lines
arch/x86/kernel/process.c +4
-0+void select_idle_routine (const struct cpuinfo_x86 *c) {#ifdef CONFIG_SMP @@ -411,6 +454,9 @@ void select_idle_routine(const struct cpuinfo_x86 *c)/* E400: APIC timer interrupt does not wake up CPU from C1e */ pr_info ("using AMD E400 aware idle routine\n" ); x86_idle = amd_e400_idle; + }else if (prefer_mwait_c1_over_halt (c)) { +pr_info ("using mwait in idle threads\n" ); + x86_idle = mwait_idle; }else x86_idle = default_idle; }
Quoted 90 lines · Andy Lutomirski
Quoted 89 lines · Len Brown
From: Len Brown <[email protected]>
In Linux-3.9 we removed the
mwait_idle()loop:
'x86 idle: removemwait_idle()and "idle=mwait" cmdline param' (69fb3676df3329a7142803bb3502fa59dc0db2e3)The reasoning was that modern machines should be sufficiently happy during the boot process using the
default_idle()HALT loop, until cpuidle loads and eitheracpi_idleorintel_idleinvoke 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=60770So 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 revert69fb3676df
for 3.10, patch -F3 applies, fuzz needed due to__cpuinituse in context For 3.11, 3.12, 3.13, this patch applies cleanlyCc Mike Galbraith <[email protected]>Cc Ian Malone <[email protected]>Cc Josh Boyer <[email protected]>Cc <[email protected]> # 3.9, 3.10, 3.11, 3.12, 3.13Signed-off-by Len Brown <[email protected]>--- arch/x86/kernel/process.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+)arch/x86/kernel/process.c +37
-0@@ -398,6 +398,49 @@ static void amd_e400_idle(void)default_idle (); } +/* +* Intel Core2 and older machines prefer MWAIT over HALT for C1. +* We can't rely on cpuidle installing MWAIT, because it will not load +* on systems that support only C1 -- so the boot default must be MWAIT. +* +* Some AMD machines are the opposite, they depend on using HALT. +* +* So for default C1, which is used during boot until cpuidle loads, +* use MWAIT-C1 on Intel HW that has it, else use HALT. +*/ +static int prefer_mwait_c1_over_halt (const struct cpuinfo_x86 *c) +{ +if (c->x86_vendor !=X86_VENDOR_INTEL ) +return 0 ; + +if (!cpu_has (c,X86_FEATURE_MWAIT )) +return 0 ; + +return 1 ; +} + +/* +* MONITOR/MWAIT with no hints, used for default default C1 state. +* This invokes MWAIT with interrutps enabled and no flags, +* which is backwards compatible with the original MWAIT implementation. +*/ + +static void mwait_idle (void ) +{ +if (!need_resched ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +clflush ((void *)¤t_thread_info ()->flags); + +__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); +smp_mb (); +if (!need_resched ()) +__sti_mwait (0 ,0 );
Quoted 8 lines
arch/x86/kernel/process.c static void amd_e400_idle(void) · line 442
Quoted 5 lines
arch/x86/kernel/process.c +5
-0+else +local_irq_enable (); + }else +local_irq_enable (); +}Admittedly, there may be relatively few users left, but SMP users on C1-only Core 2 machines can, in principle, benefit from the monitor
^hugely
Quoted 4 lines
functionality of mwait to avoid rescheduling IPIs. This stuff changed recently so it now works with the cpuidle drivers (it used to be terminally broken). Should something be twiddling
TS_POLLINGdifferently so that HLT gets the IPIs but mwait doesn't?
Urk, definitely. The IPI is the primary cause of the size large cross core scheduling performance regression for my aging, but lovely Q6600.
taskset 0xc pipe-test 1
3.8.13 3.397977 usecs/loop -- avg 3.400336 588.2 KHz
master+ 4.798547 usecs/loop -- avg 4.791692 417.4 KHz
-Mike
Quoted 4 lines · Mike Galbraith
taskset
0xcpipe-test 13.8.13 3.397977 usecs/loop -- avg 3.400336 588.2 KHz
master+ 4.798547 usecs/loop -- avg 4.791692 417.4 KHz
Bah, those are apple/grape, these are apple/apple.
idle: kill unnecessary mwait_idle() resched IPIs
Set/clear polling instead.
Q6600, pipe-test scheduling cross core:
3.8.13 487.2 KHz 1.000 3.13.0-master 415.5 KHz .852 3.13.0-master+ 415.2 KHz .852 + restore mwait_idle 3.13.0-master++ 488.5 KHz 1.002 + restore mwait_idle + IPI fix
--- arch/x86/kernel/process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/process.c +2 -2
@@ -427,18 +427,18 @@ static int prefer_mwait_c1_over_halt(constatic void mwait_idle (void ) { -if (!need_resched ()) { +if (!current_set_polling_and_test ()) {if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR ))clflush ((void *)¤t_thread_info ()->flags);__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); -smp_mb ();if (!need_resched ())__sti_mwait (0 ,0 );else local_irq_enable (); }else local_irq_enable (); +__current_clr_polling (); }void select_idle_routine (const struct cpuinfo_x86 *c)
Quoted 8 lines · Mike Galbraith
Quoted 4 lines · Mike Galbraith
taskset
0xcpipe-test 13.8.13 3.397977 usecs/loop -- avg 3.400336 588.2 KHz
master+ 4.798547 usecs/loop -- avg 4.791692 417.4 KHzBah, those are apple/grape, these are apple/apple.
Or, to make it more correct for 3.10..13, add the clflush barriers as well for afflicted CPUs.
idle: kill unnecessary mwait_idle() resched IPIs
Set/clear polling instead.
Q6600, pipe-test scheduling cross core:
3.8.13 487.2 KHz 1.000 3.13.0-master 415.5 KHz .852 3.13.0-master+ 415.2 KHz .852 + restore mwait_idle 3.13.0-master++ 488.5 KHz 1.002 + restore mwait_idle + IPI fix
--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
arch/x86/kernel/process.c +6 -3
@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(constatic void mwait_idle (void ) { -if (!need_resched ()) { -if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) +if (!current_set_polling_and_test ()) { +if (this_cpu_has (X86_FEATURE_CLFLUSH_MONITOR )) { +mb ();clflush ((void *)¤t_thread_info ()->flags); +mb (); + }__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); -smp_mb ();if (!need_resched ())__sti_mwait (0 ,0 );else local_irq_enable (); }else local_irq_enable (); +__current_clr_polling (); }void select_idle_routine (const struct cpuinfo_x86 *c)
arch/x86/kernel/process.c static int prefer_mwait_c1_over_halt(con
Quoted 12 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith
On Fri, 2014-01-17 at 05:20 +0100, Mike Galbraith wrote:
Signed-off-by Mike Galbraith <[email protected]>Cc <[email protected]> # 3.10+--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)arch/x86/kernel/process.c +0
-0@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(con
Hi, this series of patches never seem to have made it as far as the mainline kernel, anyone know what needs to happen next?
Signature · 2 lines
imalone http://ibmalone.blogspot.co.uk
Quoted 10 lines · Ian Malone
Quoted 9 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith
On Fri, 2014-01-17 at 05:20 +0100, Mike Galbraith wrote:
Signed-off-by Mike Galbraith <[email protected]>Cc <[email protected]> # 3.10+--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
Quoted 6 lines
arch/x86/kernel/process.c static int prefer_mwait_c1_over_halt(con
Quoted 3 lines
arch/x86/kernel/process.c +0
-0@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(conHi, this series of patches never seem to have made it as far as the mainline kernel, anyone know what needs to happen next?
My plan is to keep on carrying it locally for as long as I run new kernels on crusty ole core2 boxen, then stop caring about them entirely like the rest of the planet :)
-Mike
Quoted 18 lines · Mike Galbraith
Quoted 10 lines · Ian Malone
Quoted 9 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith
On Fri, 2014-01-17 at 05:20 +0100, Mike Galbraith wrote:
Signed-off-by Mike Galbraith <[email protected]>Cc <[email protected]> # 3.10+--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)Quoted 6 lines
arch/x86/kernel/process.c static int prefer_mwait_c1_over_halt(con
Quoted 3 lines
arch/x86/kernel/process.c +0
-0@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(conHi, this series of patches never seem to have made it as far as the mainline kernel, anyone know what needs to happen next?
Quoted 4 lines
My plan is to keep on carrying it locally for as long as I run new kernels on crusty ole core2 boxen, then stop caring about them entirely like the rest of the planet :)
Looks like Ingo Molnar has committed to tip which is probably a good sign, thanks all.
(Have to hand this system on to someone who wont be patching kernels...)
Signature · 2 lines
imalone http://ibmalone.blogspot.co.uk
Quoted 19 lines · Ian Malone
Quoted 18 lines · Mike Galbraith
Quoted 16 lines · Ian Malone
arch/x86/kernel/process.c static int prefer_mwait_c1_over_halt(con
Quoted 12 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith
On Fri, 2014-01-17 at 05:20 +0100, Mike Galbraith wrote:
Signed-off-by Mike Galbraith <[email protected]>Cc <[email protected]> # 3.10+--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)arch/x86/kernel/process.c +0
-0@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(conHi, this series of patches never seem to have made it as far as the mainline kernel, anyone know what needs to happen next?
Quoted 8 lines
Quoted 4 lines
My plan is to keep on carrying it locally for as long as I run new kernels on crusty ole core2 boxen, then stop caring about them entirely like the rest of the planet :)
Looks like Ingo Molnar has committed to tip which is probably a good sign, thanks all.
(Have to hand this system on to someone who wont be patching kernels...)
Guys, since I don't have the affected hardware, mind testing the latest sched/core tree:
git clone git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
cd tip
git checkout sched/core
# build a test kernel and boot it
Or if you already have a kernel git tree, do something like this to pick up the scheduler development tree:
cd linux.git
git remote add git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git tip git remote update
git checkout tip/sched/core
# build a test kernel and boot it
and check whether the mwait related bugs are now fixed for good?
Thanks,
Ingo
Quoted 41 lines · Ingo Molnar
Quoted 19 lines · Ian Malone
Quoted 18 lines · Mike Galbraith
Quoted 16 lines · Ian Malone
arch/x86/kernel/process.c static int prefer_mwait_c1_over_halt(con
Quoted 12 lines · Mike Galbraith
Quoted 1 line · Mike Galbraith
On Fri, 2014-01-17 at 05:20 +0100, Mike Galbraith wrote:
Signed-off-by Mike Galbraith <[email protected]>Cc <[email protected]> # 3.10+--- arch/x86/kernel/process.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)arch/x86/kernel/process.c +0
-0@@ -427,18 +427,21 @@ static int prefer_mwait_c1_over_halt(conHi, this series of patches never seem to have made it as far as the mainline kernel, anyone know what needs to happen next?
Quoted 8 lines
Quoted 4 lines
My plan is to keep on carrying it locally for as long as I run new kernels on crusty ole core2 boxen, then stop caring about them entirely like the rest of the planet :)
Looks like Ingo Molnar has committed to tip which is probably a good sign, thanks all.
(Have to hand this system on to someone who wont be patching kernels...)Guys, since I don't have the affected hardware, mind testing the latest sched/core tree:
git clone
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
cd tip
git checkout sched/core# build a test kernel and boot itOr if you already have a kernel git tree, do something like this to pick up the scheduler development tree:
Quoted 7 lines
cd linux.git
git remote addgit://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gittip git remote update
git checkout tip/sched/core# build a test kernel and boot itand check whether the mwait related bugs are now fixed for good?
"marge" (Q6600 box) is mostly retired now, but I'll kick her out of her rocking chair as soon as I can escape from bugzilla. All should be well, as she's been running it for ages, and ran it in master just a couple days ago.
-Mike
Quoted 19 lines · Ingo Molnar
Quoted 3 lines · Ian Malone
Looks like Ingo Molnar has committed to tip which is probably a good sign, thanks all.
(Have to hand this system on to someone who wont be patching kernels...)Guys, since I don't have the affected hardware, mind testing the latest sched/core tree:
git clone
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git
cd tip
git checkout sched/core# build a test kernel and boot itOr if you already have a kernel git tree, do something like this to pick up the scheduler development tree:
Quoted 8 lines
cd linux.git
git remote addgit://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.gittip git remote update
git checkout tip/sched/core# build a test kernel and boot itand check whether the mwait related bugs are now fixed for good?
Fixes https://bugzilla.kernel.org/show_bug.cgi?id=60770, thank you.
Signature · 2 lines
imalone http://ibmalone.blogspot.co.uk
tip-bot for Mike Galbraith
merge bot[tip:sched/core] sched/idle/x86: Optimize unnecessary mwait_idle( ) resched IPIs
In reply to Mike Galbraithsched/idle/x86: Optimize unnecessary mwait_idle() resched IPIs
Commit-ID: f8e617f4582995f7c25ef25b4167213120ad122b Gitweb: http://git.kernel.org/tip/f8e617f4582995f7c25ef25b4167213120ad122b Author: Mike Galbraith <[email protected]> AuthorDate: Sat, 18 Jan 2014 17:14:44 +0100 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 16 Mar 2015 11:14:22 +0100
sched/idle/x86: Optimize unnecessary mwait_idle() resched IPIs
To fully take advantage of MWAIT, apparently the CLFLUSH instruction needs another quirk on certain CPUs: proper barriers around it on certain machines.
On a Q6600 SMP system, pipe-test scheduling performance, cross core, improves significantly:
3.8.13 487.2 KHz 1.000 3.13.0-master 415.5 KHz .852 3.13.0-master+ 415.2 KHz .852 + restore mwait_idle 3.13.0-master++ 488.5 KHz 1.002 + restore mwait_idle + IPI fix
Since X86_BUG_CLFLUSH_MONITOR is already a quirk, don't create a separate quirk for the extra smp_mb()s.
--- arch/x86/kernel/process.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
arch/x86/kernel/process.c +8 -4
@@ -428,18 +428,22 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)static void mwait_idle (void ) { -if (!need_resched ()) { -if (this_cpu_has (X86_BUG_CLFLUSH_MONITOR )) +if (!current_set_polling_and_test ()) { +if (this_cpu_has (X86_BUG_CLFLUSH_MONITOR )) { +smp_mb ();/* quirk */ clflush ((void *)¤t_thread_info ()->flags); +smp_mb ();/* quirk */ + }__monitor ((void *)¤t_thread_info ()->flags,0 ,0 ); -smp_mb ();if (!need_resched ())__sti_mwait (0 ,0 );else local_irq_enable (); - }else + }else {local_irq_enable (); + } +__current_clr_polling (); }void select_idle_routine (const struct cpuinfo_x86 *c)
tip-bot for Len Brown
merge bot[tip:sched/core] sched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance
In reply to Len Brownsched/idle/x86: Restore mwait_idle() to fix boot hangs, to improve power savings and to improve performance
Commit-ID: b253149b843f89cd300cbdbea27ce1f847506f99 Gitweb: http://git.kernel.org/tip/b253149b843f89cd300cbdbea27ce1f847506f99 Author: Len Brown <[email protected]> AuthorDate: Wed, 15 Jan 2014 00:37:34 -0500 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 16 Mar 2015 11:14:21 +0100
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 | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)
arch/x86/include/asm/mwait.h +8 -0
@@ -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;" */ + asmvolatile ("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