Commit-ID:  f8e617f4582995f7c25ef25b4167213120ad122b
Gitweb:     http://git.kernel.org/tip/f8e617f4582995f7c25ef25b4167213120ad122b
Author:     Mike Galbraith <bitbuc...@online.de>
AuthorDate: Sat, 18 Jan 2014 17:14:44 +0100
Committer:  Ingo Molnar <mi...@kernel.org>
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.

Signed-off-by: Mike Galbraith <bitbuc...@online.de>
Cc: <sta...@vger.kernel.org> # 3.10+
Cc: Borislav Petkov <b...@alien8.de>
Cc: H. Peter Anvin <h...@zytor.com>
Cc: Ian Malone <ibmal...@gmail.com>
Cc: Josh Boyer <jwbo...@redhat.com>
Cc: Len Brown <len.br...@intel.com>
Cc: Len Brown <l...@kernel.org>
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Mike Galbraith <efa...@gmx.de>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Thomas Gleixner <t...@linutronix.de>
Link: http://lkml.kernel.org/r/1390061684.5566.4.ca...@marge.simpson.net
[ Ported to recent kernel, added comments about the quirk. ]
Signed-off-by: Ingo Molnar <mi...@kernel.org>
---
 arch/x86/kernel/process.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index da06f74..6ad8a63 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -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 *)&current_thread_info()->flags);
+                       smp_mb(); /* quirk */
+               }
 
                __monitor((void *)&current_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)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to