Commit d77d128f authored by Peter Xu's avatar Peter Xu Committed by Paolo Bonzini
Browse files

x86/asm: add cpu_relax()



This will be useful to be put inside loops.
Suggested-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Reviewed-by: Andrew Jones's avatarAndrew Jones <drjones@redhat.com>
Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 7d4c532d
......@@ -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
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment