Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors

From: Davidlohr Bueso
Date: Fri Jun 24 2016 - 12:34:56 EST


On Thu, 23 Jun 2016, Peter Zijlstra wrote:

Would something like so make sense?

---
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -188,15 +188,18 @@
#endif
#endif /* atomic_fetch_add_relaxed */

-#ifndef atomic_fetch_inc
-#define atomic_fetch_inc(v) (atomic_fetch_add(1, v))
-#endif

Hmm perhaps I'm a bit lost in all this CPP maze, but where do you in fact
define atomic_fetch_inc() generically here? gcc cannot see it either.

Another option could be to add the above for atomic_fetch_inc inside the
ifndef atomic_fetch_release. Ie:

-
/* atomic_fetch_inc_relaxed */
#ifndef atomic_fetch_inc_relaxed
+
+#ifndef atomic_fetch_inc

#define atomic_fetch_inc(v) (atomic_fetch_add(1, v))

+#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.

+#else /* atomic_fetch_inc */
#define atomic_fetch_inc_relaxed atomic_fetch_inc
#define atomic_fetch_inc_acquire atomic_fetch_inc
#define atomic_fetch_inc_release atomic_fetch_inc
+#endif /* atomic_fetch_inc */

#else /* atomic_fetch_inc_relaxed */

Thanks,
Davidlohr