[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv2 3/6] xen: generic xadd() for ticket locks
On Fri, 2015-04-10 at 15:19 +0100, David Vrabel wrote: > This is only temporary until arm/arm64 provides an xadd() > implementation. I'll assume that you aren't planning on doing this and add it to my own TODO list. Although, I'm more than willing to be preempted by another ARM dev... > > Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> > --- > xen/common/spinlock.c | 21 +++++++++++++++++++++ > 1 file changed, 21 insertions(+) > > diff --git a/xen/common/spinlock.c b/xen/common/spinlock.c > index 5fd8b1c..0c4289c 100644 > --- a/xen/common/spinlock.c > +++ b/xen/common/spinlock.c > @@ -10,6 +10,27 @@ > #include <asm/processor.h> > #include <asm/atomic.h> > > +#ifndef xadd > + > +static u32 generic_xaddl(volatile u32 *ptr, u32 v) > +{ > + u32 old, new, prev; > + > + old = read_atomic(ptr); > + for(;;) { > + new = old + v; > + prev = cmpxchg(ptr, old, new); > + if (prev == old) > + break; > + old = prev; > + } > + return old; > +} > + > +#define xadd(ptr, v) generic_xaddl((ptr), (v)) > + > +#endif > + > #ifndef NDEBUG > > static atomic_t spin_debug __read_mostly = ATOMIC_INIT(0); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |