Re: [PATCH] x86, smpboot: Call CLFLUSH only on X86_BUG_CLFLUSH_MONITOR-affected CPUs

Scotty Bauer
2015-02-11T18:39:41Z

For what its worth I tried it out and it works fine on my end.

Thanks for doing the hard work for me, Boris. Also, thanks for a pointer to the alternatives.

I think it may be worth doing a patch that is almost verbatim to this for mwait_idle_with_hints in arch/x86/include/asm/mwait.h to keep things consistent. I can work on that over the weekend.

--Scotty

On 02/06/2015 09:13 AM, Borislav Petkov wrote:
> From: Borislav Petkov <bp@suse.de>
> Subject: [PATCH] x86, smpboot: Call CLFLUSH only on X86_BUG_CLFLUSH_MONITOR-affected CPUs
>
> Make the AAI65 erratum workaround for Xeon 7400 machines only instead of
> punishing all CPUs doing idle with MWAIT with the CLFLUSH penalty.
>
> Based on a patch originally by Scotty Bauer <sbauer@eng.utah.edu>.
>
> Cc: Scotty Bauer <sbauer@eng.utah.edu>
> Signed-off-by: Borislav Petkov <bp@suse.de>
> ---
> arch/x86/kernel/smpboot.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
> index 6d7022c683e3..771ebd6e8b77 100644
> --- a/arch/x86/kernel/smpboot.c
> +++ b/arch/x86/kernel/smpboot.c
> @@ -1432,7 +1432,11 @@ static inline void mwait_play_dead(void)
> * case where we return around the loop.
> */
> mb();
> - clflush(mwait_ptr);
> +
> + asm volatile(ALTERNATIVE("", "clflush %[p]",
> + X86_BUG_CLFLUSH_MONITOR)
> + : [p] "+m" (*(unsigned long *)mwait_ptr));
> +
> mb();
> __monitor(mwait_ptr, 0, 0);
> mb();