All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC][PATCH 00/31] implement atomic_fetch_$op
@ 2016-04-22  9:04 Peter Zijlstra
  2016-04-22  9:04 ` [RFC][PATCH 01/31] locking: Flip arguments to atomic_fetch_or Peter Zijlstra
                   ` (31 more replies)
  0 siblings, 32 replies; 79+ messages in thread
From: Peter Zijlstra @ 2016-04-22  9:04 UTC (permalink / raw)
  To: torvalds, mingo, tglx, will.deacon, paulmck, boqun.feng,
	waiman.long, fweisbec
  Cc: linux-kernel, linux-arch, rth, vgupta, linux, egtvedt, realmz6,
	ysato, rkuo, tony.luck, geert, james.hogan, ralf, dhowells, jejb,
	mpe, schwidefsky, dalias, davem, cmetcalf, jcmvbkbc, arnd,
	peterz, dbueso, fengguang.wu

As there have been a few requests for atomic_fetch_$op primitives and recently
by Linus, I figured I'd go and implement the lot.

The atomic_fetch_$op differs from the existing atomic_$op_return we already
have by returning the old value instead of the new value. This is especially
useful when the operation is irreversible (like bitops), and allows for things
like test-and-set.

I did these patches on the plane, without access to architecture documentation,
so mistakes are quite possible. However, I mostly started with the
atomic_$op_return implementation and modified those to return the old value,
which significantly decreases the creativity required.

The one that I did not do was ARMv8.1-LSE and I was hoping Will would help out
with that. Also, it looks like the 0-day built bot does not do arm64 builds,
people might want to look into that.

No known build breakage on the build-bot, boot tested on x86_64.

Notes:
 - tile might have a barrier issue
 - there are a few more archs that can be converted to _relaxed if they so care:
   arc metag tile

---
 arch/alpha/include/asm/atomic.h        |  89 ++++-
 arch/arc/include/asm/atomic.h          |  67 +++-
 arch/arm/include/asm/atomic.h          | 106 +++++-
 arch/arm64/include/asm/atomic.h        |  30 ++
 arch/arm64/include/asm/atomic_ll_sc.h  | 108 ++++--
 arch/avr32/include/asm/atomic.h        |  54 ++-
 arch/blackfin/include/asm/atomic.h     |   8 +
 arch/blackfin/kernel/bfin_ksyms.c      |   1 +
 arch/blackfin/mach-bf561/atomic.S      |  43 ++-
 arch/frv/include/asm/atomic.h          |  30 +-
 arch/frv/include/asm/atomic_defs.h     |   2 +
 arch/h8300/include/asm/atomic.h        |  29 +-
 arch/hexagon/include/asm/atomic.h      |  31 +-
 arch/ia64/include/asm/atomic.h         | 130 ++++++-
 arch/m32r/include/asm/atomic.h         |  36 +-
 arch/m68k/include/asm/atomic.h         |  51 ++-
 arch/metag/include/asm/atomic_lnkget.h |  36 +-
 arch/metag/include/asm/atomic_lock1.h  |  33 +-
 arch/mips/include/asm/atomic.h         | 154 +++++++-
 arch/mn10300/include/asm/atomic.h      |  33 +-
 arch/parisc/include/asm/atomic.h       |  63 +++-
 arch/powerpc/include/asm/atomic.h      |  83 ++++-
 arch/s390/include/asm/atomic.h         |  40 ++-
 arch/sh/include/asm/atomic-grb.h       |  34 +-
 arch/sh/include/asm/atomic-irq.h       |  31 +-
 arch/sh/include/asm/atomic-llsc.h      |  32 +-
 arch/sparc/include/asm/atomic_32.h     |  13 +-
 arch/sparc/include/asm/atomic_64.h     |  16 +-
 arch/sparc/lib/atomic32.c              |  29 +-
 arch/sparc/lib/atomic_64.S             |  61 +++-
 arch/sparc/lib/ksyms.c                 |  17 +-
 arch/tile/include/asm/atomic.h         |   2 +
 arch/tile/include/asm/atomic_32.h      |  60 +++-
 arch/tile/include/asm/atomic_64.h      | 117 ++++--
 arch/tile/include/asm/bitops_32.h      |  18 +-
 arch/tile/lib/atomic_32.c              |  42 +--
 arch/tile/lib/atomic_asm_32.S          |  14 +-
 arch/x86/include/asm/atomic.h          |  35 +-
 arch/x86/include/asm/atomic64_32.h     |  25 +-
 arch/x86/include/asm/atomic64_64.h     |  35 +-
 arch/xtensa/include/asm/atomic.h       |  52 ++-
 include/asm-generic/atomic-long.h      |  36 +-
 include/asm-generic/atomic.h           |  47 +++
 include/asm-generic/atomic64.h         |  15 +-
 include/linux/atomic.h                 | 627 ++++++++++++++++++++++++---------
 kernel/locking/qrwlock.c               |   2 +-
 kernel/locking/qspinlock_paravirt.h    |   4 +-
 kernel/time/tick-sched.c               |   4 +-
 lib/atomic64.c                         |  32 +-
 lib/atomic64_test.c                    |  34 ++
 50 files changed, 2181 insertions(+), 510 deletions(-)

^ permalink raw reply	[flat|nested] 79+ messages in thread

end of thread, other threads:[~2016-05-02  8:16 UTC | newest]

Thread overview: 79+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-22  9:04 [RFC][PATCH 00/31] implement atomic_fetch_$op Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 01/31] locking: Flip arguments to atomic_fetch_or Peter Zijlstra
2016-04-22 10:54   ` Will Deacon
2016-04-22 11:09   ` Geert Uytterhoeven
2016-04-22 11:09     ` Geert Uytterhoeven
2016-04-22 14:18     ` Peter Zijlstra
2016-04-22 14:18       ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 02/31] locking,alpha: Implement atomic{,64}_fetch_{add,sub,and,andnot,or,xor}() Peter Zijlstra
2016-04-22 16:57   ` Richard Henderson
2016-04-23  1:55     ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 03/31] locking,arc: Implement atomic_fetch_{add,sub,and,andnot,or,xor}() Peter Zijlstra
2016-04-22 10:50   ` Vineet Gupta
2016-04-22 10:50     ` Vineet Gupta
2016-04-22 14:16     ` Peter Zijlstra
2016-04-22 14:16       ` Peter Zijlstra
2016-04-25  4:26       ` Vineet Gupta
2016-04-25  4:26         ` Vineet Gupta
2016-04-22 14:26     ` Peter Zijlstra
2016-04-22 14:26       ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 04/31] locking,arm: Implement atomic{,64}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}() Peter Zijlstra
2016-04-22 11:35   ` Will Deacon
2016-04-22  9:04 ` [RFC][PATCH 05/31] locking,arm64: " Peter Zijlstra
2016-04-22 11:08   ` Will Deacon
2016-04-22 14:23   ` Will Deacon
2016-04-22 14:23     ` Will Deacon
2016-04-22 14:23     ` Will Deacon
2016-04-22  9:04 ` [RFC][PATCH 06/31] locking,avr32: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22 11:58   ` Hans-Christian Noren Egtvedt
2016-04-22  9:04 ` [RFC][PATCH 07/31] locking,blackfin: " Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 08/31] locking,frv: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 09/31] locking,h8300: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 10/31] locking,hexagon: " Peter Zijlstra
2016-04-23  2:16   ` Peter Zijlstra
2016-04-26  0:39     ` Richard Kuo
2016-04-22  9:04 ` [RFC][PATCH 11/31] locking,ia64: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 12/31] locking,m32r: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 13/31] locking,m68k: " Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 14/31] locking,metag: " Peter Zijlstra
2016-04-30  0:20   ` James Hogan
2016-04-30  0:20     ` James Hogan
2016-05-02  8:15     ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 15/31] locking,mips: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 16/31] locking,mn10300: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 17/31] locking,parisc: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 18/31] locking,powerpc: Implement atomic{,64}_fetch_{add,sub,and,or,xor}{,_relaxed,_acquire,_release}() Peter Zijlstra
2016-04-22 16:41   ` Boqun Feng
2016-04-23  2:31     ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 19/31] locking,s390: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-25  8:06   ` Martin Schwidefsky
2016-04-25  8:26     ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 20/31] locking,sh: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 21/31] locking,sparc: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 22/31] locking,tile: " Peter Zijlstra
2016-04-25 21:10   ` Chris Metcalf
2016-04-25 21:10     ` Chris Metcalf
2016-04-26 14:00     ` [PATCH] tile: clarify barrier semantics of atomic_add_return Chris Metcalf
     [not found]   ` <571E840A.8090703@mellanox.com>
2016-04-26 15:28     ` [RFC][PATCH 22/31] locking,tile: Implement atomic{,64}_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-26 15:32       ` Chris Metcalf
2016-04-26 15:32         ` Chris Metcalf
2016-04-22  9:04 ` [RFC][PATCH 23/31] locking,x86: " Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 24/31] locking,xtensa: Implement atomic_fetch_{add,sub,and,or,xor}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 25/31] locking: Fix atomic64_relaxed bits Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 26/31] locking: Implement atomic{,64,_long}_fetch_{add,sub,and,andnot,or,xor}{,_relaxed,_acquire,_release}() Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 27/31] locking: Remove linux/atomic.h:atomic_fetch_or Peter Zijlstra
2016-04-22 13:02   ` Will Deacon
2016-04-22 14:21     ` Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 28/31] locking: Remove the deprecated atomic_{set,clear}_mask() functions Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 29/31] locking,alpha: Convert to _relaxed atomics Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 30/31] locking,mips: " Peter Zijlstra
2016-04-22  9:04 ` [RFC][PATCH 31/31] locking,qrwlock: Employ atomic_fetch_add_acquire() Peter Zijlstra
2016-04-22 14:25   ` Waiman Long
2016-04-22 14:25     ` Waiman Long
2016-04-22  9:44 ` [RFC][PATCH 00/31] implement atomic_fetch_$op Peter Zijlstra
2016-04-22 12:56   ` Fengguang Wu
2016-04-22 13:03     ` Will Deacon
2016-04-22 14:23     ` Peter Zijlstra
2016-04-23  1:59       ` Fengguang Wu
2016-04-22 18:35     ` Kalle Valo
2016-04-23  3:23       ` Fengguang Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.