Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-19 Thread Jamie Lokier
Peter Maydell wrote: > On 19 September 2012 14:32, Jamie Lokier wrote: > > However, someone may run QEMU on a kernel before 2.6.32, which isn't > > that old. (E.g. my phone is running 2.6.28). > > NB that ARM kernels that old have other amusing bugs, such > as not saving the floating point regis

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-19 Thread Peter Maydell
On 19 September 2012 14:32, Jamie Lokier wrote: > However, someone may run QEMU on a kernel before 2.6.32, which isn't > that old. (E.g. my phone is running 2.6.28). NB that ARM kernels that old have other amusing bugs, such as not saving the floating point registers when invoking signal handler

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-19 Thread Jamie Lokier
liu ping fan wrote: > >> +static inline void atomic_set(Atomic *v, int i) > >> +{ > >> +v->counter = i; > >> +} Hi, When running on ARM Linux kernels prior to 2.6.32, userspace atomic_set() needs to use "clrex" or "strex" too. See Linux commit 200b812d, "Clear the exclusive monitor when retu

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-19 Thread Jamie Lokier
Avi Kivity wrote: > On 09/13/2012 09:54 AM, liu ping fan wrote: > > >>> +typedef struct Atomic { > >>> +int counter; > >>> +} Atomic; > >> > >> Best to mark counter 'volatile'. > >> > >>> + > >>> +static inline void atomic_set(Atomic *v, int i) > >>> +{ > >>> +v->counter = i; > >>> +} > >>

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-13 Thread liu ping fan
On Thu, Sep 13, 2012 at 4:19 PM, Paolo Bonzini wrote: > Il 13/09/2012 10:14, Avi Kivity ha scritto: > >>> +static inline void atomic_set(Atomic *v, int i) > >>> +{ > >>> +v->counter = i; > >>> +} > >>> + > >>> +static inline int atomic_read(Atomic *v) > >>> +{ >

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-13 Thread Paolo Bonzini
Il 13/09/2012 10:23, Avi Kivity ha scritto: >> > But I don't really see the point in wrapping atomically-accessed >> > variables in a struct. > Preventing accidental naked access (to be reported in patch review as > "wardrobe malfunction"). Yeah, I understand that, but it's rare enough that I do

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-13 Thread Avi Kivity
On 09/13/2012 11:19 AM, Paolo Bonzini wrote: > Il 13/09/2012 10:14, Avi Kivity ha scritto: > >>> +static inline void atomic_set(Atomic *v, int i) > >>> +{ > >>> +v->counter = i; > >>> +} > >>> + > >>> +static inline int atomic_read(Atomic *v) > >>> +{ > >>> +

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-13 Thread Paolo Bonzini
Il 13/09/2012 10:14, Avi Kivity ha scritto: >>> +static inline void atomic_set(Atomic *v, int i) >>> +{ >>> +v->counter = i; >>> +} >>> + >>> +static inline int atomic_read(Atomic *v) >>> +{ >>> +return v->counter; >>> +} >>> >>> >> >>> >> S

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-13 Thread Avi Kivity
On 09/13/2012 09:54 AM, liu ping fan wrote: >>> +typedef struct Atomic { >>> +int counter; >>> +} Atomic; >> >> Best to mark counter 'volatile'. >> >>> + >>> +static inline void atomic_set(Atomic *v, int i) >>> +{ >>> +v->counter = i; >>> +} >>> + >>> +static inline int atomic_read(Atomic

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-12 Thread liu ping fan
On Tue, Sep 11, 2012 at 4:04 PM, Avi Kivity wrote: > On 09/11/2012 10:51 AM, Liu Ping Fan wrote: >> From: Liu Ping Fan >> >> If out of global lock, we will be challenged by SMP in low level, >> so need atomic ops. >> >> This file is a wrapper of GCC atomic builtin. >> >> Signed-off-by: Liu Ping F

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-12 Thread liu ping fan
On Tue, Sep 11, 2012 at 4:15 PM, Peter Maydell wrote: > On 11 September 2012 08:51, Liu Ping Fan wrote: >> + >> +/** >> + * * atomic_inc - increment atomic variable >> + * * @v: pointer of type Atomic >> + ** >> + * * Atomically increments @v by 1. >> + * */ > > Your editor has do

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-11 Thread Peter Maydell
On 11 September 2012 08:51, Liu Ping Fan wrote: > + > +/** > + * * atomic_inc - increment atomic variable > + * * @v: pointer of type Atomic > + ** > + * * Atomically increments @v by 1. > + * */ Your editor has done something weird with these comments. -- PMM

Re: [Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-11 Thread Avi Kivity
On 09/11/2012 10:51 AM, Liu Ping Fan wrote: > From: Liu Ping Fan > > If out of global lock, we will be challenged by SMP in low level, > so need atomic ops. > > This file is a wrapper of GCC atomic builtin. > > Signed-off-by: Liu Ping Fan > --- > include/qemu/atomic.h | 63 > ++

[Qemu-devel] [PATCH V3 01/11] atomic: introduce atomic operations

2012-09-11 Thread Liu Ping Fan
From: Liu Ping Fan If out of global lock, we will be challenged by SMP in low level, so need atomic ops. This file is a wrapper of GCC atomic builtin. Signed-off-by: Liu Ping Fan --- include/qemu/atomic.h | 63 + 1 files changed, 63 insertions