Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1608141 > unrolled thread

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

Started byStephen Rothwell <sfr@canb.auug.org.au>
First post2017-03-24 06:50 +0100
Last post2017-03-24 09:10 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  linux-next: manual merge of the akpm tree with the tip tree Stephen Rothwell <sfr@canb.auug.org.au> - 2017-03-24 06:50 +0100
    Re: linux-next: manual merge of the akpm tree with the tip tree Peter Zijlstra <peterz@infradead.org> - 2017-03-24 09:10 +0100

#1608141 — linux-next: manual merge of the akpm tree with the tip tree

FromStephen Rothwell <sfr@canb.auug.org.au>
Date2017-03-24 06:50 +0100
Subjectlinux-next: manual merge of the akpm tree with the tip tree
Message-ID<toqgO-5l2-11@gated-at.bofh.it>
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);

[toc] | [next] | [standalone]


#1608195

FromPeter Zijlstra <peterz@infradead.org>
Date2017-03-24 09:10 +0100
Message-ID<tossi-74W-21@gated-at.bofh.it>
In reply to#1608141
On Fri, Mar 24, 2017 at 04:40:26PM +1100, Stephen Rothwell wrote:
> 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.

Urgh, that patch shouldn't be in mm in any case. Also with the
try_cmpxchg() change, the text gain is reduced (about half).

Furthermore, micro-benchmarks show that turning cmpxchg loops like this
into a function makes them more expensive; see:

  https://lkml.kernel.org/r/20170322165144.dtidvvbxey7w5pbd@hirez.programming.kicks-ass.net

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web