All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] atomic_or() related changes
@ 2015-07-09  8:13 ` Vineet Gupta
  0 siblings, 0 replies; 29+ messages in thread
From: Vineet Gupta @ 2015-07-09  8:13 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnd Bergmann
  Cc: linux-arch, linux-kernel, Vineet Gupta

Hi,

This started off as an effort to convert a cmpxchg based loop in arc/kernel/smp.c
to an API which is more LLOCK/SCOND friendly.

e.g.
        do {
                new = old = ACCESS_ONCE(*ipi_data_ptr);
                new |= 1U << msg;
        } while (cmpxchg(ipi_data_ptr, old, new) != old);

The generated code is horrible. There are 2 useless branches here and a
LD/LLOCK to same address all inside a loop.

8015cefc:	ld_s       r2,[r3,0]
8015cefe:	or         r5,r2,r1
8015cf02:	llock      r4,[r3]
8015cf06:	brne       r4,r2,8015cf12
8015cf0a:	scond      r5,[r3]
8015cf0e:	bnz        8015cf02
8015cf12:	brne       r2,r4,8015cefc

An atomic_or() kind of API is better suited to generate something like below

8015cf02:	llock      r4,[r3]
8015cf06:	or         r5,r2,r1
8015cf0a:	scond      r5,[r3]
8015cf0e:	bnz        8015cf02

Although this doesn't work for the specific instance I wanted to fix as
ipi_data_ptr is not atomic_t, I did run into a few things which could be
improved, hence this series.

Compile tested on ARC, ARM, x86.

I do have some concern about mixing long and int on 64 bit arch, which I've
captured inline in patch 2/3. It is most likely a lack of understand on my
part, but worth asking..

Thx,
-Vineet

Vineet Gupta (3):
  asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_OR
  brcmfmac: dhd_sdio.c: use existing atomic_or primitive
  ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_OR

 arch/arc/include/asm/atomic.h                  |  9 +++++++++
 drivers/net/wireless/brcm80211/brcmfmac/sdio.c | 13 ++-----------
 include/asm-generic/atomic.h                   |  2 +-
 include/linux/atomic.h                         |  4 ++--
 4 files changed, 14 insertions(+), 14 deletions(-)

-- 
1.9.1

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

end of thread, other threads:[~2015-08-13 12:30 UTC | newest]

Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-09  8:13 [PATCH 0/3] atomic_or() related changes Vineet Gupta
2015-07-09  8:13 ` Vineet Gupta
2015-07-09  8:13 ` [PATCH 1/3] asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_OR Vineet Gupta
2015-07-09  8:13   ` Vineet Gupta
2015-07-09  8:13 ` [PATCH 2/3] brcmfmac: dhd_sdio.c: use existing atomic_or primitive Vineet Gupta
2015-07-09  8:13   ` Vineet Gupta
2015-07-09 18:25   ` Arend van Spriel
2015-07-09 18:25     ` Arend van Spriel
2015-07-09 18:31     ` Arend van Spriel
2015-07-09 18:31       ` Arend van Spriel
2015-07-09 19:57       ` Peter Zijlstra
2015-07-10  4:49     ` Vineet Gupta
2015-07-10  9:05       ` Arend van Spriel
2015-07-24 17:02   ` Kalle Valo
2015-07-24 17:02     ` Kalle Valo
2015-07-24 17:22     ` Vineet Gupta
2015-07-26 11:12       ` Arend van Spriel
2015-07-26 11:12         ` Arend van Spriel
2015-07-27 10:08         ` Kalle Valo
2015-07-27 10:08           ` Kalle Valo
2015-07-27 10:23           ` Vineet Gupta
2015-08-13 12:30   ` [2/3] " Kalle Valo
2015-08-13 12:30     ` Kalle Valo
2015-08-13 12:30     ` Kalle Valo
2015-07-09  8:13 ` [PATCH 3/3] ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_OR Vineet Gupta
2015-07-09  8:13   ` Vineet Gupta
2015-07-09 12:31 ` [PATCH 0/3] atomic_or() related changes Peter Zijlstra
2015-07-09 13:05   ` Vineet Gupta
2015-07-09 13:20     ` Peter Zijlstra

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.