From mboxrd@z Thu Jan 1 00:00:00 1970 From: Peter Xu Subject: Re: [PATCH kvm-unit-tests 05/17] x86/asm: add cpu_relax() Date: Tue, 8 Nov 2016 00:40:08 +0800 Message-ID: <20161107164008.GE3719@pxdev.xzpeter.org> References: <1477468040-21034-1-git-send-email-peterx@redhat.com> <1477468040-21034-6-git-send-email-peterx@redhat.com> <20161104161829.7urexhf7x5kcpkdz@kamzik.brq.redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Cc: kvm@vger.kernel.org, rkrcmar@redhat.com, agordeev@redhat.com, jan.kiszka@web.de, pbonzini@redhat.com To: Andrew Jones Return-path: Received: from mx1.redhat.com ([209.132.183.28]:48618 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbcKGQkK (ORCPT ); Mon, 7 Nov 2016 11:40:10 -0500 Content-Disposition: inline In-Reply-To: <20161104161829.7urexhf7x5kcpkdz@kamzik.brq.redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Fri, Nov 04, 2016 at 05:18:29PM +0100, Andrew Jones wrote: > 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 > > Signed-off-by: Peter Xu > > --- > > 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 > > 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. I missed that patch. Will fix and reorder. Thanks, -- peterx