Author: Andrew Cooper <[hidden email]>
AuthorDate: Fri Mar 15 12:28:46 2019 +0000
Commit: Andrew Cooper <[hidden email]>
CommitDate: Fri Mar 15 14:36:07 2019 +0000
xen/x86: Fix cflush()'s parameter tracking
Forcing a register operand hides (from the compiler) the fact that clflush
behaves as a read from the memory operand (wrt memory order, faults, etc.).
It also reduces the compilers flexibility with register scheduling.
Re-implement clfush() (and wbinvd() for consistency) as a static inline rather
than a macro, and have it take a const void pointer.
In practice, the only generated code which gets modified by this is in
mwait_idle_with_hints(), where a disp8 encoding now gets used.
While here, I noticed that &mwait_wakeup(cpu) was being calculated twice.
This is caused by the memory clobber in mb(), so take the opportunity to help
the optimiser by calculating it once, ahead of time. bloat-o-meter reports a
delta of -26 as a result of this change.
Signed-off-by: Andrew Cooper <[hidden email]>
Reviewed-by: Jan Beulich <[hidden email]>
xen/arch/x86/acpi/cpu_idle.c | 5 +++--
xen/include/asm-x86/system.h | 12 ++++++++----
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/xen/arch/x86/acpi/cpu_idle.c b/xen/arch/x86/acpi/cpu_idle.c
index 14b02789c5..654de24f40 100644
@@ -401,15 +401,16 @@ void mwait_idle_with_hints(unsigned int eax, unsigned int ecx)
unsigned int cpu = smp_processor_id();
s_time_t expires = per_cpu(timer_deadline, cpu);
+ const void *monitor_addr = &mwait_wakeup(cpu);