x86 idle: Repair large-server 50-watt idle-power regression

Linux 3.10 changed the timing of how thread_info->flags is touched:

x86: Use generic idle loop
(7d1a941731fabf27e5fb6edbebb79fe856edb4e5)

This caused Intel NHM-EX and WSM-EX servers to experience a large number
of immediate MONITOR/MWAIT break wakeups, which caused cpuidle to demote
from deep C-states to shallow C-states, which caused these platforms
to experience a significant increase in idle power.

Note that this issue was already present before the commit above,
however, it wasn't seen often enough to be noticed in power measurements.

Here we extend an errata workaround from the Core2 EX "Dunnington"
to extend to NHM-EX and WSM-EX, to prevent these immediate
returns from MWAIT, reducing idle power on these platforms.

While only acpi_idle ran on Dunnington, intel_idle
may also run on these two newer systems.
As of today, there are no other models that are known
to need this tweak.

Link: http://lkml.kernel.org/r/CAJvTdK=%2BaNN66mYpCGgbHGCHhYQAKx-vB0kJSWjVpsNb_hOAtQ@mail.gmail.com
Signed-off-by: Len Brown <len.brown@intel.com>
Link: http://lkml.kernel.org/r/baff264285f6e585df757d58b17788feabc68918.1387403066.git.len.brown@intel.com
Cc: <stable@vger.kernel.org> # 3.12.x, 3.11.x, 3.10.x
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>

authored by

Len Brown and committed by
H. Peter Anvin
40e2d7f9 319e2e3f

+5 -1
+2 -1
arch/x86/kernel/cpu/intel.c
··· 387 set_cpu_cap(c, X86_FEATURE_PEBS); 388 } 389 390 - if (c->x86 == 6 && c->x86_model == 29 && cpu_has_clflush) 391 set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); 392 393 #ifdef CONFIG_X86_64
··· 387 set_cpu_cap(c, X86_FEATURE_PEBS); 388 } 389 390 + if (c->x86 == 6 && cpu_has_clflush && 391 + (c->x86_model == 29 || c->x86_model == 46 || c->x86_model == 47)) 392 set_cpu_cap(c, X86_FEATURE_CLFLUSH_MONITOR); 393 394 #ifdef CONFIG_X86_64
+3
drivers/idle/intel_idle.c
··· 377 378 if (!current_set_polling_and_test()) { 379 380 __monitor((void *)&current_thread_info()->flags, 0, 0); 381 smp_mb(); 382 if (!need_resched())
··· 377 378 if (!current_set_polling_and_test()) { 379 380 + if (this_cpu_has(X86_FEATURE_CLFLUSH_MONITOR)) 381 + clflush((void *)&current_thread_info()->flags); 382 + 383 __monitor((void *)&current_thread_info()->flags, 0, 0); 384 smp_mb(); 385 if (!need_resched())