Message ID | 1477468040-21034-6-git-send-email-peterx@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
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@redhat.com> > Signed-off-by: Peter Xu <peterx@redhat.com> > --- > 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@redhat.com> 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@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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 <drjones@redhat.com> > > Signed-off-by: Peter Xu <peterx@redhat.com> > > --- > > 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@redhat.com> > > 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 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
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
This will be useful to be put inside loops. Suggested-by: Andrew Jones <drjones@redhat.com> Signed-off-by: Peter Xu <peterx@redhat.com> --- lib/x86/asm/barrier.h | 11 +++++++++++ 1 file changed, 11 insertions(+)