Skip to content

Commit 6cbb41b

Browse files
Mike Galbraithsashalevin
authored andcommitted
sched/idle/x86: Optimize unnecessary mwait_idle() resched IPIs
[ Upstream commit f8e617f ] 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 <bitbucket@online.de> Cc: <stable@vger.kernel.org> # 3.10+ Cc: Borislav Petkov <bp@alien8.de> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ian Malone <ibmalone@gmail.com> Cc: Josh Boyer <jwboyer@redhat.com> Cc: Len Brown <len.brown@intel.com> Cc: Len Brown <lenb@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1390061684.5566.4.camel@marge.simpson.net [ Ported to recent kernel, added comments about the quirk. ] Signed-off-by: Ingo Molnar <mingo@kernel.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent 560e644 commit 6cbb41b

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

‎arch/x86/kernel/process.c‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,22 @@ static int prefer_mwait_c1_over_halt(const struct cpuinfo_x86 *c)
428428

429429
static void mwait_idle(void)
430430
{
431-
if (!need_resched()) {
432-
if (this_cpu_has(X86_BUG_CLFLUSH_MONITOR))
431+
if (!current_set_polling_and_test()) {
432+
if (this_cpu_has(X86_BUG_CLFLUSH_MONITOR)) {
433+
smp_mb(); /* quirk */
433434
clflush((void *)&current_thread_info()->flags);
435+
smp_mb(); /* quirk */
436+
}
434437

435438
__monitor((void *)&current_thread_info()->flags, 0, 0);
436-
smp_mb();
437439
if (!need_resched())
438440
__sti_mwait(0, 0);
439441
else
440442
local_irq_enable();
441-
} else
443+
} else {
442444
local_irq_enable();
445+
}
446+
__current_clr_polling();
443447
}
444448

445449
void select_idle_routine(const struct cpuinfo_x86 *c)

0 commit comments

Comments
 (0)