[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCHv2 3/6] xen: generic xadd() for ticket locks
At 15:19 +0100 on 10 Apr (1428679194), David Vrabel wrote: > Provide a generic xadd() implementation for architectures that don't > provide one. > > This is only temporary until arm/arm64 provides an xadd() > implementation. > > Signed-off-by: David Vrabel <david.vrabel@xxxxxxxxxx> The logic looks fine, but please: - add a comment explaining what it does; and - convert it to Xen coding style to match the rest of the file. With that, Reviewed-by: Tim Deegan <tim@xxxxxxx> Cheers, Tim. > --- > 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); > -- > 1.7.10.4 > > > _______________________________________________ > Xen-devel mailing list > Xen-devel@xxxxxxxxxxxxx > http://lists.xen.org/xen-devel _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |