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

Re: [Xen-devel] [PATCH] ia64: introduce atomic_{read,write}NN()



>>> On 25.11.11 at 02:52, "KUWAMURA Shin'ya" <kuwa@xxxxxxxxxxxxxx> wrote:
> Hi Jan,
> 
> Excuse me for too late response. Thank you for your work.
> But I have a question.
> 
>>>>>> On Fri, 11 Nov 2011 16:09:25 +0000
>>>>>> JBeulich@xxxxxxxx("Jan Beulich")  said:
>> 
>> +#define build_atomic_read(tag, type) \
>> +static inline type atomic_read##tag(const volatile type *addr) \
>> +{ \
>> +    type ret; \
>> +    asm volatile("ld%2.acq %0 = %1" \
>> +                 : "=r" (ret) \
>> +                 : "m" (*addr), "i" (sizeof(type))); \
>> +    return ret; \
>> +}
>> +
>> +#define build_atomic_write(tag, type) \
>> +static inline void atomic_write##tag(volatile type *addr, type val) \
>> +{ \
>> +    asm volatile("st%2.rel %0 = %1" \
>> +                 : "=m" (*addr) \
>> +                 : "r" (val), "i" (sizeof(type))); \
>> +}
> 
> Why do you use explicitly ld.acq and st.rel?
> I think that volatile variables are always accessed using ld.acq and
> st.rel and they are not required.

That would imply the compiler would attach these completers, but in
inline assembly it obviously can't.

> For example, The implementation of Linux is as follows:
> 
> #define atomic_read(v)                (*(volatile int *)&(v)->counter)
> #define atomic64_read(v)      (*(volatile long *)&(v)->counter)

Indeed - here the compiler is required to use acquire loads and
release stores. The inline assembly has to mimic this behavior.

Jan


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


 


Rackspace

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