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

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

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

KUWAMURA Shin'ya
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
>>>>> [hidden email]("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.
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)

Best regards,
--
  KUWAMURA Shin'ya

_______________________________________________
Xen-ia64-devel mailing list
[hidden email]
http://lists.xensource.com/xen-ia64-devel