lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20160623090942.GI30154@twins.programming.kicks-ass.net>
Date:	Thu, 23 Jun 2016 11:09:42 +0200
From:	Peter Zijlstra <peterz@...radead.org>
To:	Davidlohr Bueso <dave@...olabs.net>
Cc:	mingo@...nel.org, davem@...emloft.net, cw00.choi@...sung.com,
	dougthompson@...ssion.com, bp@...en8.de, mchehab@....samsung.com,
	gregkh@...uxfoundation.org, pfg@....com, jikos@...nel.org,
	hans.verkuil@...co.com, awalls@...metrocast.net,
	dledford@...hat.com, sean.hefty@...el.com, kys@...rosoft.com,
	heiko.carstens@...ibm.com, James.Bottomley@...senPartnership.com,
	sumit.semwal@...aro.org, schwidefsky@...ibm.com,
	linux-kernel@...r.kernel.org, Davidlohr Bueso <dbueso@...e.de>
Subject: Re: [PATCH v2 01/12] locking/atomic: Introduce inc/dec calls for
 FETCH-OP flavors

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@...olabs.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 */
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ