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-02-23 08:46:04 -08:00
2017-03-06 10:30:57 +00:00
2017-02-27 19:59:21 -08:00
2017-03-01 09:50:58 -08:00
2017-02-23 11:27:49 -08:00
2017-02-22 10:15:09 -08:00
2017-02-27 18:43:46 -08:00
2017-02-27 19:59:21 -08:00
2017-03-09 17:01:09 -08:00
2017-03-03 01:45:41 +01:00
2017-02-23 15:57:04 -08:00
2017-02-27 18:43:46 -08:00
2017-03-02 08:42:32 +01:00
2017-03-23 08:54:40 +01:00
2017-02-21 13:25:50 -08:00
2017-03-02 08:32:46 +01:00
2017-03-03 01:45:23 +01:00
2017-02-27 20:54:05 +02:00
2017-03-02 08:56:04 -07:00
2017-03-08 10:55:17 -07:00
2017-02-24 17:46:56 -08:00
2017-03-02 08:42:25 +01:00
2017-02-24 17:46:55 -08:00
2017-02-27 18:43:45 -08:00
2017-03-01 20:32:25 +01:00
2017-02-27 23:09:29 -08:00
2017-03-02 08:42:40 +01:00
2017-03-02 13:53:13 -08:00
2017-03-02 08:42:38 +01:00
2017-03-02 08:42:31 +01:00
2017-02-24 17:46:54 -08:00
2017-03-02 08:42:24 +01:00
2017-02-23 20:33:51 -08:00
2017-03-03 01:45:28 +01:00
2017-02-25 13:45:43 -08:00
2017-02-24 17:46:55 -08:00
2017-02-25 13:45:43 -08:00
2017-03-02 08:42:38 +01:00
2017-03-02 08:42:36 +01:00
2017-02-27 10:07:47 -08:00
2017-03-03 01:45:28 +01:00
2017-02-21 17:56:45 -08:00
2017-03-01 20:32:25 +01:00
2017-03-09 17:01:09 -08:00
2017-02-23 20:33:51 -08:00
2017-03-08 10:55:17 -07:00
2017-02-24 17:46:55 -08:00
2017-03-03 01:45:40 +01:00
2017-02-24 17:46:54 -08:00
2017-03-09 11:48:47 -08:00
2017-03-02 08:42:32 +01:00
2017-03-03 01:43:47 +01:00
2017-02-24 17:46:54 -08:00
2017-02-24 17:46:56 -08:00
2017-03-06 14:40:04 +00:00
2017-03-07 09:37:28 -08:00
2017-03-09 11:48:47 -08:00
2017-02-27 18:43:47 -08:00
2017-02-24 17:46:57 -08:00
2017-03-02 10:09:00 +11:00
2017-03-02 08:42:28 +01:00
2017-02-27 18:43:45 -08:00
2017-03-02 08:42:28 +01:00
2017-03-01 17:03:21 +01:00
2017-02-21 17:21:32 -08:00
2017-03-01 00:49:42 -08:00
2017-03-16 09:57:07 +01:00
2017-03-02 12:17:22 -08:00
2017-02-24 17:46:57 -08:00
2017-02-24 17:46:54 -08:00
2017-02-22 16:41:27 -08:00
2017-02-24 17:46:56 -08:00
2017-02-24 17:46:55 -08:00
2017-02-23 09:54:19 -08:00
2017-02-24 17:46:54 -08:00
2017-03-03 01:45:25 +01:00
2017-03-03 01:43:48 +01:00
2017-03-09 11:48:47 -08:00
2017-02-24 17:46:54 -08:00
2017-02-24 17:46:54 -08:00
2017-03-16 09:57:08 +01:00
2017-02-23 11:53:22 -08:00
2017-03-01 09:50:58 -08:00
2017-03-02 20:51:15 -05:00
2017-03-03 01:43:38 +01:00
2017-02-22 13:34:00 -07:00
2017-02-22 13:34:00 -07:00
2017-02-22 19:23:14 -08:00
2017-03-02 08:42:29 +01:00
2017-02-22 16:41:30 -08:00
2017-03-02 08:56:04 -07:00
2017-03-16 09:57:08 +01:00
2017-03-02 08:42:36 +01:00
2017-02-24 17:46:54 -08:00
2017-02-24 17:46:56 -08:00
2017-03-02 08:42:38 +01:00
2017-03-03 00:43:11 +01:00
2017-03-03 01:43:47 +01:00
2017-03-02 08:42:29 +01:00
2017-03-10 20:55:09 +01:00
2017-02-24 17:46:57 -08:00
2017-03-02 08:42:24 +01:00
2017-03-02 08:42:24 +01:00
2017-03-02 08:42:24 +01:00
2017-03-13 07:41:08 +01:00
2017-03-02 08:42:38 +01:00
2017-02-24 17:46:55 -08:00
2017-02-27 18:43:48 -08:00
2017-03-03 01:45:41 +01:00
2017-02-23 20:33:51 -08:00
2017-02-23 11:55:41 -07:00
2017-02-27 18:43:46 -08:00
2017-02-24 17:46:56 -08:00
2017-03-03 01:43:48 +01:00
2017-03-03 01:43:48 +01:00
2017-03-02 08:42:29 +01:00
2017-03-02 08:42:27 +01:00
2017-02-22 16:41:27 -08:00
2017-02-22 16:41:27 -08:00
2017-03-02 20:51:15 -05:00
2017-02-22 16:41:30 -08:00
2017-02-22 16:41:30 -08:00
2017-03-02 20:51:15 -05:00
2017-03-02 08:42:29 +01:00
2017-03-03 01:45:25 +01:00
2017-03-03 01:45:25 +01:00
2017-03-03 01:45:39 +01:00
2017-02-22 16:41:26 -08:00
2017-03-06 15:26:37 -06:00
2017-03-09 17:01:10 -08:00
2017-02-27 20:54:05 +02:00
2017-03-09 17:01:10 -08:00
2017-03-02 08:42:25 +01:00
2017-03-08 10:36:03 -08:00
2017-02-24 14:00:23 -08:00
2017-02-24 17:46:54 -08:00