[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH 16/17] xen: arm: refactor xchg and cmpxchg into their own headers



On Thu, 2014-03-20 at 17:52 +0000, Julien Grall wrote:
> Hi Ian,
> 
> On 03/20/2014 03:46 PM, Ian Campbell wrote:
> > diff --git a/xen/include/asm-arm/arm32/cmpxchg.h 
> > b/xen/include/asm-arm/arm32/cmpxchg.h
> > new file mode 100644
> > index 0000000..70c6090
> > --- /dev/null
> > +++ b/xen/include/asm-arm/arm32/cmpxchg.h
> > +static always_inline unsigned long __cmpxchg(
> > +    volatile void *ptr, unsigned long old, unsigned long new, int size)
> > +{
> > +   unsigned long oldval, res;
> > +
> > +   switch (size) {
> > +   case 1:
> > +           do {
> > +                   asm volatile("@ __cmpxchg1\n"
> > +                   "       ldrexb  %1, [%2]\n"
> > +                   "       mov     %0, #0\n"
> > +                   "       teq     %1, %3\n"
> > +                   "       strexbeq %0, %4, [%2]\n"
> > +                           : "=&r" (res), "=&r" (oldval)
> > +                           : "r" (ptr), "Ir" (old), "r" (new)
> > +                           : "memory", "cc");
> > +           } while (res);
> > +           break;
> > +   case 2:
> > +           do {
> > +                   asm volatile("@ __cmpxchg2\n"
> > +                   "       ldrexh  %1, [%2]\n"
> > +                   "       mov     %0, #0\n"
> > +                   "       teq     %1, %3\n"
> > +                   "       strexheq %0, %4, [%2]\n"
> > +                           : "=&r" (res), "=&r" (oldval)
> > +                           : "r" (ptr), "Ir" (old), "r" (new)
> > +                           : "memory", "cc");
> > +           } while (res);
> > +           break;
> > +   case 4:
> > +           do {
> > +                   asm volatile("@ __cmpxchg4\n"
> > +                   "       ldrex   %1, [%2]\n"
> > +                   "       mov     %0, #0\n"
> > +                   "       teq     %1, %3\n"
> > +                   "       strexeq %0, %4, [%2]\n"
> > +                           : "=&r" (res), "=&r" (oldval)
> > +                           : "r" (ptr), "Ir" (old), "r" (new)
> > +                           : "memory", "cc");
> > +       } while (res);
> > +       break;
> > +#if 0
> > +   case 8:
> > +           do {
> > +                   asm volatile("@ __cmpxchg8\n"
> > +                   "       ldrexd  %1, [%2]\n"
> > +                   "       mov     %0, #0\n"
> > +                   "       teq     %1, %3\n"
> > +                   "       strexdeq %0, %4, [%2]\n"
> > +                           : "=&r" (res), "=&r" (oldval)
> > +                           : "r" (ptr), "Ir" (old), "r" (new)
> > +                           : "memory", "cc");
> > +           } while (res);
> > +           break;
> > +#endif
> 
> Is it really useful to let the dead code in the header?

This was a pure code motion patch so I'm not going to remove it here.

In any case this will come in handy the first time someone tries to
cmpxchg an 8 byte value.

Ian.


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.