lkml.org 
[lkml]   [2015]   [May]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] x86/alternatives: Switch AMD F15h and later to the P6 NOPs
    Date
    From: Borislav Petkov <bp@suse.de>

    Software optimization guides for both F15h and F16h cite those NOPs as
    the optimal ones. A microbenchmark confirms that actually even older
    families are better with the single-insn NOPs so switch to them for the
    alternatives.

    Cycles count below includes the loop overhead of the measurement but
    that overhead is the same with all runs.

    F10h, revE:
    -----------
    Running NOP tests, 1000 NOPs x 1000000 repetitions

    K8:
    90 288.212282 cycles
    66 90 288.220840 cycles
    66 66 90 288.219447 cycles
    66 66 66 90 288.223204 cycles
    66 66 90 66 90 571.393424 cycles
    66 66 90 66 66 90 571.374919 cycles
    66 66 66 90 66 66 90 572.249281 cycles
    66 66 66 90 66 66 66 90 571.388651 cycles

    P6:
    90 288.214193 cycles
    66 90 288.225550 cycles
    0f 1f 00 288.224441 cycles
    0f 1f 40 00 288.225030 cycles
    0f 1f 44 00 00 288.233558 cycles
    66 0f 1f 44 00 00 324.792342 cycles
    0f 1f 80 00 00 00 00 325.657462 cycles
    0f 1f 84 00 00 00 00 00 430.246643 cycles

    F14h:
    ----
    Running NOP tests, 1000 NOPs x 1000000 repetitions

    K8:
    90 510.404890 cycles
    66 90 510.432117 cycles
    66 66 90 510.561858 cycles
    66 66 66 90 510.541865 cycles
    66 66 90 66 90 1014.192782 cycles
    66 66 90 66 66 90 1014.226546 cycles
    66 66 66 90 66 66 90 1014.334299 cycles
    66 66 66 90 66 66 66 90 1014.381205 cycles

    P6:
    90 510.436710 cycles
    66 90 510.448229 cycles
    0f 1f 00 510.545100 cycles
    0f 1f 40 00 510.502792 cycles
    0f 1f 44 00 00 510.589517 cycles
    66 0f 1f 44 00 00 510.611462 cycles
    0f 1f 80 00 00 00 00 511.166794 cycles
    0f 1f 84 00 00 00 00 00 511.651641 cycles

    F15h:
    -----
    Running NOP tests, 1000 NOPs x 1000000 repetitions

    K8:
    90 243.128396 cycles
    66 90 243.129883 cycles
    66 66 90 243.131631 cycles
    66 66 66 90 242.499324 cycles
    66 66 90 66 90 481.829083 cycles
    66 66 90 66 66 90 481.884413 cycles
    66 66 66 90 66 66 90 481.851446 cycles
    66 66 66 90 66 66 66 90 481.409220 cycles

    P6:
    90 243.127026 cycles
    66 90 243.130711 cycles
    0f 1f 00 243.122747 cycles
    0f 1f 40 00 242.497617 cycles
    0f 1f 44 00 00 245.354461 cycles
    66 0f 1f 44 00 00 361.930417 cycles
    0f 1f 80 00 00 00 00 362.844944 cycles
    0f 1f 84 00 00 00 00 00 480.514948 cycles

    F16h:
    -----
    Running NOP tests, 1000 NOPs x 1000000 repetitions

    K8:
    90 507.793298 cycles
    66 90 507.789636 cycles
    66 66 90 507.826490 cycles
    66 66 66 90 507.859075 cycles
    66 66 90 66 90 1008.663129 cycles
    66 66 90 66 66 90 1008.696259 cycles
    66 66 66 90 66 66 90 1008.692517 cycles
    66 66 66 90 66 66 66 90 1008.755399 cycles

    P6:
    90 507.795232 cycles
    66 90 507.794761 cycles
    0f 1f 00 507.834901 cycles
    0f 1f 40 00 507.822629 cycles
    0f 1f 44 00 00 507.838493 cycles
    66 0f 1f 44 00 00 507.908597 cycles
    0f 1f 80 00 00 00 00 507.946417 cycles
    0f 1f 84 00 00 00 00 00 507.954960 cycles

    Signed-off-by: Borislav Petkov <bp@suse.de>
    Cc: Aravind Gopalakrishnan <aravind.gopalakrishnan@amd.com>
    ---
    arch/x86/kernel/alternative.c | 9 +++++++++
    1 file changed, 9 insertions(+)

    diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
    index aef653193160..b0932c4341b3 100644
    --- a/arch/x86/kernel/alternative.c
    +++ b/arch/x86/kernel/alternative.c
    @@ -227,6 +227,15 @@ void __init arch_init_ideal_nops(void)
    #endif
    }
    break;
    +
    + case X86_VENDOR_AMD:
    + if (boot_cpu_data.x86 > 0xf) {
    + ideal_nops = p6_nops;
    + return;
    + }
    +
    + /* fall through */
    +
    default:
    #ifdef CONFIG_X86_64
    ideal_nops = k8_nops;
    --
    2.3.5


    \
     
     \ /
      Last update: 2015-05-11 10:41    [W:4.349 / U:0.048 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site