Re: [PATCH kvm-unit-tests 05/17] x86/asm: add cpu_relax()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 26, 2016 at 03:47:08PM +0800, Peter Xu wrote:
> This will be useful to be put inside loops.
> 
> Suggested-by: Andrew Jones <drjones@xxxxxxxxxx>
> Signed-off-by: Peter Xu <peterx@xxxxxxxxxx>
> ---
>  lib/x86/asm/barrier.h | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/lib/x86/asm/barrier.h b/lib/x86/asm/barrier.h
> index 7c108bd..193fb4c 100644
> --- a/lib/x86/asm/barrier.h
> +++ b/lib/x86/asm/barrier.h
> @@ -13,4 +13,15 @@
>  #define smp_rmb()	barrier()
>  #define smp_wmb()	barrier()
>  
> +/* REP NOP (PAUSE) is a good thing to insert into busy-wait loops. */
> +static inline void rep_nop(void)
> +{
> +	asm volatile("rep; nop" ::: "memory");
> +}
> +
> +static inline void cpu_relax(void)
> +{
> +	rep_nop();
> +}
> +
>  #endif
> -- 
> 2.7.4

Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx>

But this should be the first patch of the series, because your current
first patch already introduces one busy-wait loop where it could be used.

drew
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux