Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1180528
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
| Newsgroups | linux.kernel |
| Subject | [PATCH 0/3] atomic_or() related changes |
| Date | Thu, 09 Jul 2015 10:20:01 +0200 |
| Message-ID | <pKfdL-6cK-3@gated-at.bofh.it> (permalink) |
| X-Original-To | Peter Zijlstra <peterz@infradead.org>, Ingo Molnar <mingo@kernel.org>, Arnd Bergmann <arnd@arndb.de> |
| X-Mailer | git-send-email 1.9.1 |
| MIME-Version | 1.0 |
| Content-Type | text/plain |
| X-Originating-IP | [10.12.197.226] |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 61 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | <linux-arch@vger.kernel.org>, <linux-kernel@vger.kernel.org>, Vineet Gupta <Vineet.Gupta1@synopsys.com> |
| X-Original-Date | Thu, 9 Jul 2015 13:43:16 +0530 |
| X-Original-Message-ID | <1436429599-10762-1-git-send-email-vgupta@synopsys.com> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | aioe.org linux.kernel:1180528 |
Show key headers only | View raw
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Next in thread | Find similar | Unroll thread
[PATCH 0/3] atomic_or() related changes Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-07-09 10:20 +0200
[PATCH 3/3] ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_OR Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-07-09 10:20 +0200
[PATCH 1/3] asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_OR Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-07-09 10:20 +0200
Re: [PATCH 0/3] atomic_or() related changes Peter Zijlstra <peterz@infradead.org> - 2015-07-09 14:40 +0200
Re: [PATCH 0/3] atomic_or() related changes Vineet Gupta <Vineet.Gupta1@synopsys.com> - 2015-07-09 15:10 +0200
csiph-web