[CRIU] [PATCH 5/5] x86: atomic -- Adopt code from linux kernel
Cyrill Gorcunov
gorcunov at openvz.org
Fri Feb 15 08:48:20 EST 2013
On Fri, Feb 15, 2013 at 05:28:42PM +0400, Pavel Emelyanov wrote:
> On 02/06/2013 12:04 AM, Cyrill Gorcunov wrote:
> >
> > This allow us to eliminate "asm/types.h" inclusion as well,
> > together with simplifying the code.
> >
> > Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
> > ---
> > arch/x86/include/asm/atomic.h | 92 +++++++++++++++++++------------------------
> > include/lock.h | 3 +-
> > 2 files changed, 43 insertions(+), 52 deletions(-)
> >
>
>
> > @@ -119,7 +119,8 @@ static void inline mutex_lock(mutex_t *m)
> > u32 c;
> > int ret;
> >
> > - while ((c = atomic_inc(&m->raw))) {
> > + while ((c = atomic_read(&m->raw))) {
> > + atomic_inc(&m->raw);
>
> This is not equal change. It was while (atomic_get_and_inc) now its while (atomic_get) atomic_inc.
Which actually doesn't change much. Look, atomic_inc was incrementing value and
returning its previous meaning, now we do the same but this looks as "two"
operations from C code, but the cycle below is constructed to be lockless so you will
not get any harm in such transition. I rather feel sorry that I wrote it in
"lock xchg" manner earlier.
More information about the CRIU
mailing list