Skip to content

x86/asm: avoid register pressure from the init case in static_cpu_has()

H. Peter Anvin (Intel) lkml 2 versions – Applied

Status from this message: The following commit has been merged into the x86/cpu branch of tip:

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 0 repliesApplied
  2. v22 patches 2 repliesSuperseded

Changes in v3 from the cover letter

--------------
* Clarify the subject line

Patches in v3 Applied

#Subject and filesSizeRepliesApplied
1/2x86/asm: add _ASM_RIP() macro for x86-64 (%rip) suffixarch/x86/include/asm/asm.h+5 -00 replies
2/2x86/asm: avoid adding register pressure for the init case in static_cpu_has()arch/x86/include/asm/cpufeature.h+9 -40 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/2] x86/asm: avoid register pressure from the init case in static_cpu_has()

gcc will sometimes manifest the address of boot_cpu_data in a register as part of constant propagation. When multiple static_cpu_has() are used this may foul the mainline code with a register load which will only be used on the fallback path, which is unused after initialization.

Explicitly force gcc to use immediate (rip-relative) addressing for the fallback path, thus removing any possible register use from static_cpu_has().

However, currently there is no convenient way to make gcc generate a %rip-relative immediate reference without splitting code into i386 and x86-64 versions, so add a new macro to <asm/asm.h> for this purpose.

Changes in v3:
--------------
* Clarify the subject line

Changes in v2:
--------------
* Add new macro to <asm/asm.h>
* *Actually* generate the %rip-relative addressing mode.

 arch/x86/include/asm/asm.h        |  5 +++++
 arch/x86/include/asm/cpufeature.h | 13 +++++++++----
 2 files changed, 14 insertions(+), 4 deletions(-)