x86, cpu: Change NOP selection for certain Intel CPUs
authorH. Peter Anvin <[email protected]>
Mon, 18 Apr 2011 22:31:57 +0000 (15:31 -0700)
committerH. Peter Anvin <[email protected]>
Mon, 18 Apr 2011 23:40:32 +0000 (16:40 -0700)
Due to a decoder implementation quirk, some specific Intel CPUs
actually perform better with the "k8_nops" than with the
SDM-recommended NOPs.  For runtime-selected NOPs, if we detect those
specific CPUs then use the k8_nops instead of the ones we would
normally use.

Signed-off-by: H. Peter Anvin <[email protected]>
Cc: Tejun Heo <[email protected]>
Cc: Steven Rostedt <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Jason Baron <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
arch/x86/kernel/alternative.c

index 846f61eb89c147870e802a3df7ed98075a7645e8..c0501ea6b634cd4b998ef7002b6ff8b93fc14d05 100644 (file)
@@ -199,7 +199,19 @@ void __init arch_init_ideal_nops(void)
 {
        switch (boot_cpu_data.x86_vendor) {
        case X86_VENDOR_INTEL:
-               if (boot_cpu_has(X86_FEATURE_NOPL)) {
+               /*
+                * Due to a decoder implementation quirk, some
+                * specific Intel CPUs actually perform better with
+                * the "k8_nops" than with the SDM-recommended NOPs.
+                */
+               if (boot_cpu_data.x86 == 6 &&
+                   boot_cpu_data.x86_model >= 0x0f &&
+                   boot_cpu_data.x86_model != 0x1c &&
+                   boot_cpu_data.x86_model != 0x26 &&
+                   boot_cpu_data.x86_model != 0x27 &&
+                   boot_cpu_data.x86_model < 0x30) {
+                       ideal_nops = k8_nops;
+               } else if (boot_cpu_has(X86_FEATURE_NOPL)) {
                           ideal_nops = p6_nops;
                } else {
 #ifdef CONFIG_X86_64