Skip to content

Commit cf62120

Browse files
suryasaimadhuZhengShunQian
authored andcommitted
x86/cpufeature: Speed up cpu_feature_enabled()
commit f2cc8e0 upstream When GCC cannot do constant folding for this macro, it falls back to cpu_has(). But static_cpu_has() is optimal and it works at all times now. So use it and speedup the fallback case. Before we had this: mov 0x99d674(%rip),%rdx # ffffffff81b0d9f4 <boot_cpu_data+0x34> shr $0x2e,%rdx and $0x1,%edx jne ffffffff811704e9 <do_munmap+0x3f9> After alternatives patching, it turns into: jmp 0xffffffff81170390 nopl (%rax) ... callq ffffffff81056e00 <mpx_notify_unmap> ffffffff81170390: mov 0x170(%r12),%rdi Signed-off-by: Borislav Petkov <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Ingo Molnar <[email protected]> Signed-off-by: Srivatsa S. Bhat <[email protected]> Reviewed-by: Matt Helsley (VMware) <[email protected]> Reviewed-by: Alexey Makhalov <[email protected]> Reviewed-by: Bo Gan <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 3ffe4b9 commit cf62120

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

arch/x86/include/asm/cpufeature.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
8888
* is not relevant.
8989
*/
9090
#define cpu_feature_enabled(bit) \
91-
(__builtin_constant_p(bit) && DISABLED_MASK_BIT_SET(bit) ? 0 : \
92-
cpu_has(&boot_cpu_data, bit))
91+
(__builtin_constant_p(bit) && DISABLED_MASK_BIT_SET(bit) ? 0 : static_cpu_has(bit))
9392

9493
#define boot_cpu_has(bit) cpu_has(&boot_cpu_data, bit)
9594

0 commit comments

Comments
 (0)