Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1426990 > unrolled thread
| Started by | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| First post | 2016-06-20 22:10 +0200 |
| Last post | 2016-06-23 11:20 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors Davidlohr Bueso <dave@stgolabs.net> - 2016-06-20 22:10 +0200
Re: [PATCH 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors Peter Zijlstra <peterz@infradead.org> - 2016-06-21 09:30 +0200
[PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors Davidlohr Bueso <dave@stgolabs.net> - 2016-06-21 15:40 +0200
Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors Davidlohr Bueso <dave@stgolabs.net> - 2016-06-21 19:20 +0200
Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors Peter Zijlstra <peterz@infradead.org> - 2016-06-23 11:20 +0200
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Date | 2016-06-20 22:10 +0200 |
| Subject | [PATCH 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors |
| Message-ID | <rMdGa-4no-13@gated-at.bofh.it> |
With the inclusion of atomic FETCH-OP variants, many places in the kernel can make use of atomic_fetch_$op() to avoid the hacky callers that need to compute the value/state _before_ the operation. Peter laid out the machinery but we are still missing the simpler dec,inc calls (which future patches will make use of). This patch only deals with the generic code, as at least right now no arch actually implement them -- which is similar to what the OP-RETURN primitives currently do. Signed-off-by: Davidlohr Bueso <dbueso@suse.de> --- include/linux/atomic.h | 104 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/include/linux/atomic.h b/include/linux/atomic.h index 12d910d61b83..3017dd7ee654 100644 --- a/include/linux/atomic.h +++ b/include/linux/atomic.h @@ -188,6 +188,34 @@ #endif #endif /* atomic_fetch_add_relaxed */ +/* atomic_fetch_inc_relaxed */ +#ifndef atomic_fetch_inc_relaxed +#define atomic_fetch_inc_relaxed atomic_fetch_inc +#define atomic_fetch_inc_acquire atomic_fetch_inc +#define atomic_fetch_inc_release atomic_fetch_inc + +#else /* atomic_fetch_inc_relaxed */ + +#ifndef atomic_fetch_inc_acquire +#define atomic_fetch_inc_acquire(...) \ + __atomic_op_acquire(atomic_fetch_inc, __VA_ARGS__) +#endif + +#ifndef atomic_fetch_inc_release +#define atomic_fetch_inc_release(...) \ + __atomic_op_release(atomic_fetch_inc, __VA_ARGS__) +#endif + +#ifndef atomic_fetch_add +#define atomic_fetch_add(...) \ + __atomic_op_fence(atomic_fetch_inc, __VA_ARGS__) +#endif +#endif /* atomic_fetch_inc_relaxed */ + +#ifndef atomic_fetch_inc +#define atomic_fetch_inc(v) (atomic_fetch_add(1, v)) +#endif + /* atomic_fetch_sub_relaxed */ #ifndef atomic_fetch_sub_relaxed #define atomic_fetch_sub_relaxed atomic_fetch_sub @@ -212,6 +240,34 @@ #endif #endif /* atomic_fetch_sub_relaxed */ +/* atomic_fetch_dec_relaxed */ +#ifndef atomic_fetch_dec_relaxed +#define atomic_fetch_dec_relaxed atomic_fetch_dec +#define atomic_fetch_dec_acquire atomic_fetch_dec +#define atomic_fetch_dec_release atomic_fetch_dec + +#else /* atomic_fetch_dec_relaxed */ + +#ifndef atomic_fetch_dec_acquire +#define atomic_fetch_dec_acquire(...) \ + __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__) +#endif + +#ifndef atomic_fetch_dec_release +#define atomic_fetch_dec_release(...) \ + __atomic_op_release(atomic_fetch_dec, __VA_ARGS__) +#endif + +#ifndef atomic_fetch_dec +#define atomic_fetch_dec(...) \ + __atomic_op_fence(atomic_fetch_dec, __VA_ARGS__) +#endif +#endif /* atomic_fetch_dec_relaxed */ + +#ifndef atomic_fetch_dec +#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v)) +#endif + /* atomic_fetch_or_relaxed */ #ifndef atomic_fetch_or_relaxed #define atomic_fetch_or_relaxed atomic_fetch_or @@ -697,6 +753,30 @@ static inline int atomic_dec_if_positive(atomic_t *v) #endif #endif /* atomic64_fetch_add_relaxed */ +/* atomic64_fetch_inc_relaxed */ +#ifndef atomic64_fetch_inc_relaxed +#define atomic64_fetch_inc_relaxed atomic64_fetch_inc +#define atomic64_fetch_inc_acquire atomic64_fetch_inc +#define atomic64_fetch_inc_release atomic64_fetch_inc + +#else /* atomic64_fetch_inc_relaxed */ + +#ifndef atomic64_fetch_inc_acquire +#define atomic64_fetch_inc_acquire(...) \ + __atomic_op_acquire(atomic64_fetch_inc, __VA_ARGS__) +#endif + +#ifndef atomic64_fetch_inc_release +#define atomic64_fetch_inc_release(...) \ + __atomic_op_release(atomic64_fetch_inc, __VA_ARGS__) +#endif + +#ifndef atomic64_fetch_inc +#define atomic64_fetch_inc(...) \ + __atomic_op_fence(atomic64_fetch_inc, __VA_ARGS__) +#endif +#endif /* atomic64_fetch_inc_relaxed */ + /* atomic64_fetch_sub_relaxed */ #ifndef atomic64_fetch_sub_relaxed #define atomic64_fetch_sub_relaxed atomic64_fetch_sub @@ -721,6 +801,30 @@ static inline int atomic_dec_if_positive(atomic_t *v) #endif #endif /* atomic64_fetch_sub_relaxed */ +/* atomic64_fetch_dec_relaxed */ +#ifndef atomic64_fetch_dec_relaxed +#define atomic64_fetch_dec_relaxed atomic64_fetch_dec +#define atomic64_fetch_dec_acquire atomic64_fetch_dec +#define atomic64_fetch_dec_release atomic64_fetch_dec + +#else /* atomic64_fetch_dec_relaxed */ + +#ifndef atomic64_fetch_dec_acquire +#define atomic64_fetch_dec_acquire(...) \ + __atomic_op_acquire(atomic64_fetch_dec, __VA_ARGS__) +#endif + +#ifndef atomic64_fetch_dec_release +#define atomic64_fetch_dec_release(...) \ + __atomic_op_release(atomic64_fetch_dec, __VA_ARGS__) +#endif + +#ifndef atomic64_fetch_dec +#define atomic64_fetch_dec(...) \ + __atomic_op_fence(atomic64_fetch_dec, __VA_ARGS__) +#endif +#endif /* atomic64_fetch_dec_relaxed */ + /* atomic64_fetch_or_relaxed */ #ifndef atomic64_fetch_or_relaxed #define atomic64_fetch_or_relaxed atomic64_fetch_or -- 2.6.6
[toc] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-06-21 09:30 +0200 |
| Subject | Re: [PATCH 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors |
| Message-ID | <rMoie-2I5-35@gated-at.bofh.it> |
| In reply to | #1426990 |
On Mon, Jun 20, 2016 at 01:05:53PM -0700, Davidlohr Bueso wrote: > +#ifndef atomic_fetch_inc > +#define atomic_fetch_inc(v) (atomic_fetch_add(1, v)) > +#endif > +#ifndef atomic_fetch_dec > +#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v)) > +#endif You're missing these for atomic64
[toc] | [prev] | [next] | [standalone]
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Date | 2016-06-21 15:40 +0200 |
| Subject | [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors |
| Message-ID | <rMu4h-6rf-3@gated-at.bofh.it> |
| In reply to | #1426990 |
With the inclusion of atomic FETCH-OP variants, many places in the
kernel can make use of atomic_fetch_$op() to avoid the hacky callers
that need to compute the value/state _before_ the operation. Peter
laid out the machinery but we are still missing the simpler dec,inc
calls (which future patches will make use of).
This patch only deals with the generic code, as at least right now
no arch actually implement them -- which is similar to what the
OP-RETURN primitives currently do.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
Changes from v1: added atomic64 flavors, only define atomic_fetch_inc/dec once,
the fence logic will come through the add/sub calls instead.
include/linux/atomic.h | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 96 insertions(+)
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 12d910d61b83..c848d89bc9a0 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -188,6 +188,29 @@
#endif
#endif /* atomic_fetch_add_relaxed */
+#ifndef atomic_fetch_inc
+#define atomic_fetch_inc(v) (atomic_fetch_add(1, v))
+#endif
+
+/* atomic_fetch_inc_relaxed */
+#ifndef atomic_fetch_inc_relaxed
+#define atomic_fetch_inc_relaxed atomic_fetch_inc
+#define atomic_fetch_inc_acquire atomic_fetch_inc
+#define atomic_fetch_inc_release atomic_fetch_inc
+
+#else /* atomic_fetch_inc_relaxed */
+
+#ifndef atomic_fetch_inc_acquire
+#define atomic_fetch_inc_acquire(...) \
+ __atomic_op_acquire(atomic_fetch_inc, __VA_ARGS__)
+#endif
+
+#ifndef atomic_fetch_inc_release
+#define atomic_fetch_inc_release(...) \
+ __atomic_op_release(atomic_fetch_inc, __VA_ARGS__)
+#endif
+#endif /* atomic_fetch_inc_relaxed */
+
/* atomic_fetch_sub_relaxed */
#ifndef atomic_fetch_sub_relaxed
#define atomic_fetch_sub_relaxed atomic_fetch_sub
@@ -212,6 +235,33 @@
#endif
#endif /* atomic_fetch_sub_relaxed */
+#ifndef atomic_fetch_dec
+#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v))
+#endif
+
+/* atomic_fetch_dec_relaxed */
+#ifndef atomic_fetch_dec_relaxed
+#define atomic_fetch_dec_relaxed atomic_fetch_dec
+#define atomic_fetch_dec_acquire atomic_fetch_dec
+#define atomic_fetch_dec_release atomic_fetch_dec
+
+#else /* atomic_fetch_dec_relaxed */
+
+#ifndef atomic_fetch_dec_acquire
+#define atomic_fetch_dec_acquire(...) \
+ __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__)
+#endif
+
+#ifndef atomic_fetch_dec_release
+#define atomic_fetch_dec_release(...) \
+ __atomic_op_release(atomic_fetch_dec, __VA_ARGS__)
+#endif
+#endif /* atomic_fetch_dec_relaxed */
+
+#ifndef atomic_fetch_dec
+#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v))
+#endif
+
/* atomic_fetch_or_relaxed */
#ifndef atomic_fetch_or_relaxed
#define atomic_fetch_or_relaxed atomic_fetch_or
@@ -697,6 +747,29 @@ static inline int atomic_dec_if_positive(atomic_t *v)
#endif
#endif /* atomic64_fetch_add_relaxed */
+#ifndef atomic64_fetch_inc
+#define atomic64_fetch_inc(v) (atomic64_fetch_add(1, v))
+#endif
+
+/* atomic64_fetch_inc_relaxed */
+#ifndef atomic64_fetch_inc_relaxed
+#define atomic64_fetch_inc_relaxed atomic64_fetch_inc
+#define atomic64_fetch_inc_acquire atomic64_fetch_inc
+#define atomic64_fetch_inc_release atomic64_fetch_inc
+
+#else /* atomic64_fetch_inc_relaxed */
+
+#ifndef atomic64_fetch_inc_acquire
+#define atomic64_fetch_inc_acquire(...) \
+ __atomic_op_acquire(atomic64_fetch_inc, __VA_ARGS__)
+#endif
+
+#ifndef atomic64_fetch_inc_release
+#define atomic64_fetch_inc_release(...) \
+ __atomic_op_release(atomic64_fetch_inc, __VA_ARGS__)
+#endif
+#endif /* atomic64_fetch_inc_relaxed */
+
/* atomic64_fetch_sub_relaxed */
#ifndef atomic64_fetch_sub_relaxed
#define atomic64_fetch_sub_relaxed atomic64_fetch_sub
@@ -721,6 +794,29 @@ static inline int atomic_dec_if_positive(atomic_t *v)
#endif
#endif /* atomic64_fetch_sub_relaxed */
+#ifndef atomic64_fetch_dec
+#define atomic64_fetch_dec(v) (atomic64_fetch_sub(1, v))
+#endif
+
+/* atomic64_fetch_dec_relaxed */
+#ifndef atomic64_fetch_dec_relaxed
+#define atomic64_fetch_dec_relaxed atomic64_fetch_dec
+#define atomic64_fetch_dec_acquire atomic64_fetch_dec
+#define atomic64_fetch_dec_release atomic64_fetch_dec
+
+#else /* atomic64_fetch_dec_relaxed */
+
+#ifndef atomic64_fetch_dec_acquire
+#define atomic64_fetch_dec_acquire(...) \
+ __atomic_op_acquire(atomic64_fetch_dec, __VA_ARGS__)
+#endif
+
+#ifndef atomic64_fetch_dec_release
+#define atomic64_fetch_dec_release(...) \
+ __atomic_op_release(atomic64_fetch_dec, __VA_ARGS__)
+#endif
+#endif /* atomic64_fetch_dec_relaxed */
+
/* atomic64_fetch_or_relaxed */
#ifndef atomic64_fetch_or_relaxed
#define atomic64_fetch_or_relaxed atomic64_fetch_or
--
2.6.6
[toc] | [prev] | [next] | [standalone]
| From | Davidlohr Bueso <dave@stgolabs.net> |
|---|---|
| Date | 2016-06-21 19:20 +0200 |
| Subject | Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors |
| Message-ID | <rMxvb-ii-9@gated-at.bofh.it> |
| In reply to | #1427756 |
Sorry, I was also missing the _long variants. While at it I added a missing
ATOMIC_LONG_FETCH_INC_DEC_OP undef.
--------------8<-----------------------------
From: Davidlohr Bueso <dave@stgolabs.net>
Subject: [PATCH -v3 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors
With the inclusion of atomic FETCH-OP variants, many places in the
kernel can make use of atomic_fetch_$op() to avoid the hacky callers
that need to compute the value/state _before_ the operation. Peter
laid out the machinery but we are still missing the simpler dec,inc
calls (which future patches will make use of).
This patch only deals with the generic code, as at least right now
no arch actually implement them -- which is similar to what the
OP-RETURN primitives currently do.
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
include/asm-generic/atomic-long.h | 22 +++++++++
include/linux/atomic.h | 96 +++++++++++++++++++++++++++++++++++++++
2 files changed, 118 insertions(+)
diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
index 2d0d3cf791ab..288cc9e96395 100644
--- a/include/asm-generic/atomic-long.h
+++ b/include/asm-generic/atomic-long.h
@@ -146,6 +146,28 @@ ATOMIC_LONG_FETCH_OP(xor, _relaxed)
ATOMIC_LONG_FETCH_OP(xor, _acquire)
ATOMIC_LONG_FETCH_OP(xor, _release)
+#undef ATOMIC_LONG_FETCH_OP
+
+#define ATOMIC_LONG_FETCH_INC_DEC_OP(op, mo) \
+static inline long \
+atomic_long_fetch_##op##mo(atomic_long_t *l) \
+{ \
+ ATOMIC_LONG_PFX(_t) *v = (ATOMIC_LONG_PFX(_t) *)l; \
+ \
+ return (long)ATOMIC_LONG_PFX(_fetch_##op##mo)(v); \
+}
+
+ATOMIC_LONG_FETCH_INC_DEC_OP(inc,)
+ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _relaxed)
+ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _acquire)
+ATOMIC_LONG_FETCH_INC_DEC_OP(inc, _release)
+ATOMIC_LONG_FETCH_INC_DEC_OP(dec,)
+ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _relaxed)
+ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _acquire)
+ATOMIC_LONG_FETCH_INC_DEC_OP(dec, _release)
+
+#undef ATOMIC_LONG_FETCH_INC_DEC_OP
+
#define ATOMIC_LONG_OP(op) \
static __always_inline void \
atomic_long_##op(long i, atomic_long_t *l) \
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 12d910d61b83..c848d89bc9a0 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -188,6 +188,29 @@
#endif
#endif /* atomic_fetch_add_relaxed */
+#ifndef atomic_fetch_inc
+#define atomic_fetch_inc(v) (atomic_fetch_add(1, v))
+#endif
+
+/* atomic_fetch_inc_relaxed */
+#ifndef atomic_fetch_inc_relaxed
+#define atomic_fetch_inc_relaxed atomic_fetch_inc
+#define atomic_fetch_inc_acquire atomic_fetch_inc
+#define atomic_fetch_inc_release atomic_fetch_inc
+
+#else /* atomic_fetch_inc_relaxed */
+
+#ifndef atomic_fetch_inc_acquire
+#define atomic_fetch_inc_acquire(...) \
+ __atomic_op_acquire(atomic_fetch_inc, __VA_ARGS__)
+#endif
+
+#ifndef atomic_fetch_inc_release
+#define atomic_fetch_inc_release(...) \
+ __atomic_op_release(atomic_fetch_inc, __VA_ARGS__)
+#endif
+#endif /* atomic_fetch_inc_relaxed */
+
/* atomic_fetch_sub_relaxed */
#ifndef atomic_fetch_sub_relaxed
#define atomic_fetch_sub_relaxed atomic_fetch_sub
@@ -212,6 +235,33 @@
#endif
#endif /* atomic_fetch_sub_relaxed */
+#ifndef atomic_fetch_dec
+#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v))
+#endif
+
+/* atomic_fetch_dec_relaxed */
+#ifndef atomic_fetch_dec_relaxed
+#define atomic_fetch_dec_relaxed atomic_fetch_dec
+#define atomic_fetch_dec_acquire atomic_fetch_dec
+#define atomic_fetch_dec_release atomic_fetch_dec
+
+#else /* atomic_fetch_dec_relaxed */
+
+#ifndef atomic_fetch_dec_acquire
+#define atomic_fetch_dec_acquire(...) \
+ __atomic_op_acquire(atomic_fetch_dec, __VA_ARGS__)
+#endif
+
+#ifndef atomic_fetch_dec_release
+#define atomic_fetch_dec_release(...) \
+ __atomic_op_release(atomic_fetch_dec, __VA_ARGS__)
+#endif
+#endif /* atomic_fetch_dec_relaxed */
+
+#ifndef atomic_fetch_dec
+#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v))
+#endif
+
/* atomic_fetch_or_relaxed */
#ifndef atomic_fetch_or_relaxed
#define atomic_fetch_or_relaxed atomic_fetch_or
@@ -697,6 +747,29 @@ static inline int atomic_dec_if_positive(atomic_t *v)
#endif
#endif /* atomic64_fetch_add_relaxed */
+#ifndef atomic64_fetch_inc
+#define atomic64_fetch_inc(v) (atomic64_fetch_add(1, v))
+#endif
+
+/* atomic64_fetch_inc_relaxed */
+#ifndef atomic64_fetch_inc_relaxed
+#define atomic64_fetch_inc_relaxed atomic64_fetch_inc
+#define atomic64_fetch_inc_acquire atomic64_fetch_inc
+#define atomic64_fetch_inc_release atomic64_fetch_inc
+
+#else /* atomic64_fetch_inc_relaxed */
+
+#ifndef atomic64_fetch_inc_acquire
+#define atomic64_fetch_inc_acquire(...) \
+ __atomic_op_acquire(atomic64_fetch_inc, __VA_ARGS__)
+#endif
+
+#ifndef atomic64_fetch_inc_release
+#define atomic64_fetch_inc_release(...) \
+ __atomic_op_release(atomic64_fetch_inc, __VA_ARGS__)
+#endif
+#endif /* atomic64_fetch_inc_relaxed */
+
/* atomic64_fetch_sub_relaxed */
#ifndef atomic64_fetch_sub_relaxed
#define atomic64_fetch_sub_relaxed atomic64_fetch_sub
@@ -721,6 +794,29 @@ static inline int atomic_dec_if_positive(atomic_t *v)
#endif
#endif /* atomic64_fetch_sub_relaxed */
+#ifndef atomic64_fetch_dec
+#define atomic64_fetch_dec(v) (atomic64_fetch_sub(1, v))
+#endif
+
+/* atomic64_fetch_dec_relaxed */
+#ifndef atomic64_fetch_dec_relaxed
+#define atomic64_fetch_dec_relaxed atomic64_fetch_dec
+#define atomic64_fetch_dec_acquire atomic64_fetch_dec
+#define atomic64_fetch_dec_release atomic64_fetch_dec
+
+#else /* atomic64_fetch_dec_relaxed */
+
+#ifndef atomic64_fetch_dec_acquire
+#define atomic64_fetch_dec_acquire(...) \
+ __atomic_op_acquire(atomic64_fetch_dec, __VA_ARGS__)
+#endif
+
+#ifndef atomic64_fetch_dec_release
+#define atomic64_fetch_dec_release(...) \
+ __atomic_op_release(atomic64_fetch_dec, __VA_ARGS__)
+#endif
+#endif /* atomic64_fetch_dec_relaxed */
+
/* atomic64_fetch_or_relaxed */
#ifndef atomic64_fetch_or_relaxed
#define atomic64_fetch_or_relaxed atomic64_fetch_or
--
2.6.6
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2016-06-23 11:20 +0200 |
| Subject | Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors |
| Message-ID | <rN8XL-7PN-1@gated-at.bofh.it> |
| In reply to | #1427980 |
On Tue, Jun 21, 2016 at 09:36:11AM -0700, Davidlohr Bueso wrote: > Sorry, I was also missing the _long variants. While at it I added a missing > ATOMIC_LONG_FETCH_INC_DEC_OP undef. > > --------------8<----------------------------- > From: Davidlohr Bueso <dave@stgolabs.net> > Subject: [PATCH -v3 01/12] locking/atomic: Introduce inc/dec calls for FETCH-OP flavors > > With the inclusion of atomic FETCH-OP variants, many places in the > kernel can make use of atomic_fetch_$op() to avoid the hacky callers > that need to compute the value/state _before_ the operation. Peter > laid out the machinery but we are still missing the simpler dec,inc > calls (which future patches will make use of). > > This patch only deals with the generic code, as at least right now > no arch actually implement them -- which is similar to what the > OP-RETURN primitives currently do. 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 - /* atomic_fetch_inc_relaxed */ #ifndef atomic_fetch_inc_relaxed + +#ifndef atomic_fetch_inc +#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)) +#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 */ @@ -235,15 +238,18 @@ #endif #endif /* atomic_fetch_sub_relaxed */ -#ifndef atomic_fetch_dec -#define atomic_fetch_dec(v) (atomic_fetch_sub(1, v)) -#endif - /* atomic_fetch_dec_relaxed */ #ifndef atomic_fetch_dec_relaxed + +#ifndef atomic_fetch_dec +#define atomic_fetch_dec_relaxed(v) atomic_fetch_sub_relaxed(1, (v)) +#define atomic_fetch_dec_acquire(v) atomic_fetch_sub_acquire(1, (v)) +#define atomic_fetch_dec_release(v) atomic_fetch_sub_release(1, (v)) +#else /* atomic_fetch_dec */ #define atomic_fetch_dec_relaxed atomic_fetch_dec #define atomic_fetch_dec_acquire atomic_fetch_dec #define atomic_fetch_dec_release atomic_fetch_dec +#endif /* atomic_fetch_dec */ #else /* atomic_fetch_dec_relaxed */ @@ -753,9 +759,16 @@ static inline int atomic_dec_if_positive /* atomic64_fetch_inc_relaxed */ #ifndef atomic64_fetch_inc_relaxed + +#ifndef atomic64_fetch_inc +#define atomic64_fetch_inc_relaxed(v) atomic64_fetch_add_relaxed(1, (v)) +#define atomic64_fetch_inc_acquire(v) atomic64_fetch_add_acquire(1, (v)) +#define atomic64_fetch_inc_release(v) atomic64_fetch_add_release(1, (v)) +#else /* atomic64_fetch_inc */ #define atomic64_fetch_inc_relaxed atomic64_fetch_inc #define atomic64_fetch_inc_acquire atomic64_fetch_inc #define atomic64_fetch_inc_release atomic64_fetch_inc +#endif /* atomic64_fetch_inc */ #else /* atomic64_fetch_inc_relaxed */ @@ -794,15 +807,18 @@ static inline int atomic_dec_if_positive #endif #endif /* atomic64_fetch_sub_relaxed */ -#ifndef atomic64_fetch_dec -#define atomic64_fetch_dec(v) (atomic64_fetch_sub(1, v)) -#endif - /* atomic64_fetch_dec_relaxed */ #ifndef atomic64_fetch_dec_relaxed + +#ifndef atomic64_fetch_dec +#define atomic64_fetch_dec_relaxed(v) atomic64_fetch_sub_relaxed(1, (v)) +#define atomic64_fetch_dec_acquire(v) atomic64_fetch_sub_acquire(1, (v)) +#define atomic64_fetch_dec_release(v) atomic64_fetch_sub_release(1, (v)) +#else /* atomic64_fetch_dec */ #define atomic64_fetch_dec_relaxed atomic64_fetch_dec #define atomic64_fetch_dec_acquire atomic64_fetch_dec #define atomic64_fetch_dec_release atomic64_fetch_dec +#endif /* atomic64_fetch_dec */ #else /* atomic64_fetch_dec_relaxed */
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web