Files
kernel/include/linux
Peter Zijlstra a9ebf306f5 locking/atomic: Introduce atomic_try_cmpxchg()
Add a new cmpxchg interface:

  bool try_cmpxchg(u{8,16,32,64} *ptr, u{8,16,32,64} *val, u{8,16,32,64} new);

Where the boolean returns the result of the compare; and thus if the
exchange happened; and in case of failure, the new value of *ptr is
returned in *val.

This allows simplification/improvement of loops like:

	for (;;) {
		new = val $op $imm;
		old = cmpxchg(ptr, val, new);
		if (old == val)
			break;
		val = old;
	}

into:

	do {
	} while (!try_cmpxchg(ptr, &val, val $op $imm));

while also generating better code (GCC6 and onwards).

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2017-03-23 08:54:40 +01:00
..
2017-03-07 14:30:38 +01:00
2017-01-24 12:37:43 -08:00
2017-03-01 09:50:58 -08:00
2017-02-10 15:52:24 -05:00
2017-03-02 08:56:04 -07:00
2017-01-25 13:17:47 -05:00
2017-02-24 17:46:55 -08:00
2017-02-04 00:47:59 +01:00
2017-02-27 10:07:47 -08:00
2017-02-11 20:59:41 -05:00
2017-01-05 15:01:55 -06:00
2017-02-01 09:13:45 +01:00
2017-02-24 17:46:57 -08:00
2017-01-12 16:48:26 -05:00
2017-03-01 09:50:58 -08:00
2017-03-02 08:56:04 -07:00
2017-02-20 10:15:11 -05:00
2017-02-13 21:44:09 -05:00
2017-02-27 18:43:46 -08:00
2017-01-09 16:07:38 -05:00
2017-02-03 11:19:34 -05:00
2017-01-10 18:31:55 -08:00
2017-02-03 10:17:02 +01:00
2017-02-10 16:34:17 +00:00
2017-01-11 09:21:41 +01:00
2017-02-02 15:22:18 -05:00