Subject: linux-next: manual merge of the akpm tree with the tip tree

From: Stephen Rothwell <[email-masked]>
Date: Fri, 24 Mar 2017 16:40:26 +1100

Hi all,

Today's linux-next merge of the akpm tree got a conflict in:

  arch/x86/include/asm/atomic.h

between commit:

  e6790e4b5d5e ("locking/atomic/x86: Use atomic_try_cmpxchg()")

from the tip tree and patch:

  "x86/atomic: move __arch_atomic_add_unless out of line"

from the akpm tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --git a/arch/x86/lib/atomic.c b/arch/x86/lib/atomic.c
index 88c8372109f8..4b8f6b842be9 100644
--- a/arch/x86/lib/atomic.c
+++ b/arch/x86/lib/atomic.c
@@ -12,16 +12,11 @@
  */
 int __arch_atomic_add_unless(atomic_t *v, int a, int u)
 {
-	int c, old;
-	c = arch_atomic_read(v);
-	for (;;) {
-		if (unlikely(c == (u)))
+	int c = arch_atomic_read(v);
+	do {
+		if (unlikely(c == u))
 			break;
-		old = arch_atomic_cmpxchg((v), c, c + (a));
-		if (likely(old == c))
-			break;
-		c = old;
-	}
+	} while (!atomic_try_cmpxchg(v, &c, c + a));
 	return c;
 }
 EXPORT_SYMBOL(__arch_atomic_add_unless);