Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors
From: Peter Zijlstra
Date: Fri Jun 24 2016 - 14:49:33 EST
On Fri, Jun 24, 2016 at 09:34:30AM -0700, Davidlohr Bueso wrote:
> On Thu, 23 Jun 2016, Peter Zijlstra wrote:
>
> >-
> >/* atomic_fetch_inc_relaxed */
> >#ifndef atomic_fetch_inc_relaxed
> >+
> >+#ifndef atomic_fetch_inc
>
> #define atomic_fetch_inc(v) (atomic_fetch_add(1, v))
Ah yes.
> >+#define atomic_fetch_inc_relaxed(v) atomic_fetch_add_relaxed(1, (v))
> >+#define atomic_fetch_inc_acquire(v) atomic_fetch_add_acquire(1, (v))
> >+#define atomic_fetch_inc_release(v) atomic_fetch_add_release(1, (v))
>
> I was under the impression that if the archs don't define their own calls,
> then we always default to fully ordered. Which is why I based all this ifdefery
> on what is currently done with the other atomic_fetch_$ops.
Right, but this allows an arch to only define atomic_fetch_add_relaxed()
and have the various forms of fetch_inc() instantiated as well.
With your earlier version they would all fall back to the fully
sequential variant of fetch_add().