linux-mips
[Top] [All Lists]

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

To: "Russell King - ARM Linux" <linux@arm.linux.org.uk>, "Sven Eckelmann" <sven@narfation.org>
Subject: RE: Re: [PATCHv5] atomic: add *_dec_not_zero
From: "David Laight" <David.Laight@ACULAB.COM>
Date: Mon, 5 Dec 2011 11:44:10 -0000
Cc: <linux-m32r-ja@ml.linux-m32r.org>, <linux-mips@linux-mips.org>, <linux-ia64@vger.kernel.org>, <linux-doc@vger.kernel.org>, "H. Peter Anvin" <hpa@zytor.com>, "Heiko Carstens" <heiko.carstens@de.ibm.com>, "Randy Dunlap" <rdunlap@xenotime.net>, "Paul Mackerras" <paulus@samba.org>, "Helge Deller" <deller@gmx.de>, <sparclinux@vger.kernel.org>, <linux-hexagon@vger.kernel.org>, <linux-arch@vger.kernel.org>, <linux-s390@vger.kernel.org>, <user-mode-linux-devel@lists.sourceforge.net>, "Richard Weinberger" <richard@nod.at>, "Hirokazu Takata" <takata@linux-m32r.org>, <x86@kernel.org>, "James E.J. Bottomley" <jejb@parisc-linux.org>, "Ingo Molnar" <mingo@redhat.com>, "Matt Turner" <mattst88@gmail.com>, "Fenghua Yu" <fenghua.yu@intel.com>, "Arnd Bergma nn" <arnd@arndb.de>, "Jeff Dike" <jdike@addtoit.com>, "Chris Metcalf" <cmetcalf@tilera.com>, <linux-m32r@ml.linux-m32r.org>, "Ivan Kokshaysky" <ink@jurassic.park.msu.ru>, "Thomas Gleixner" <tglx@linutronix.de>, <linux-arm-kernel@lists.infradead.org>, "Richard Henderson" <rth@twiddle.net>, "Tony Luck" <tony.luck@intel.com>, <linux-parisc@vger.kernel.org>, <b.a.t.m.a.n@lists.open-mesh.org>, <linux-kernel@vger.kernel.org>, "Ralf Baechle" <ralf@linux-mips.org>, "Kyle McMartin" <kyle@mcmartin.ca>, <linux-alpha@vger.kernel.org>, "Martin Schwidefsky" <schwidefsky@de.ibm.com>, <linux390@de.ibm.com>, "Andrew Morton" <akpm@linux-foundation.org>, <linuxppc-dev@lists.ozlabs.org>, "David S. Miller" <davem@davemloft.net>
In-reply-to: <20111204221850.GC14542@n2100.arm.linux.org.uk>
Sender: linux-mips-bounce@linux-mips.org
Thread-index: Acyy0x4HjkbAO+BaTWSu0XHw1HNtUwAb8ndQ
Thread-topic: Re: [PATCHv5] atomic: add *_dec_not_zero
Looking at this:

> #ifndef atomic_inc_unless_negative
> static inline int atomic_inc_unless_negative(atomic_t *p)
> {
>         int v, v1;
>         for (v = 0; v >= 0; v = v1) {
>                 v1 = atomic_cmpxchg(p, v, v + 1);
>                 if (likely(v1 == 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



<Prev in Thread] Current Thread [Next in Thread>