Thread (10 messages) 10 messages, 5 authors, 2011-12-05

RE: Re: [PATCHv5] atomic: add *_dec_not_zero

From: David Laight <hidden>
Date: 2011-12-05 11:44:10
Also in: batman, linux-alpha, linux-arch, linux-arm-kernel, linux-mips, linux-um

Looking at this:
#ifndef atomic_inc_unless_negative
static inline int atomic_inc_unless_negative(atomic_t *p)
{
        int v, v1;
        for (v =3D 0; v >=3D 0; v =3D v1) {
                v1 =3D atomic_cmpxchg(p, v, v + 1);
                if (likely(v1 =3D=3D v))
                        return 1;
        }
        return 0;
}
#endif
why is it optimised for '*p' being zero??
I'd have though the initial assignment to 'v' should
be made by reading '*p' without any memory barriers (etc).

	David
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help