Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1180528 > unrolled thread
| Started by | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| First post | 2015-07-09 10:20 +0200 |
| Last post | 2015-07-09 15:10 +0200 |
| Articles | 5 — 2 participants |
Back to article view | Back to linux.kernel
[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
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2015-07-09 10:20 +0200 |
| Subject | [PATCH 0/3] atomic_or() related changes |
| Message-ID | <pKfdL-6cK-3@gated-at.bofh.it> |
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/
[toc] | [next] | [standalone]
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2015-07-09 10:20 +0200 |
| Subject | [PATCH 3/3] ARC: provide atomic_or() and define ARCH_HAS_ATOMIC_OR |
| Message-ID | <pKfdL-6cK-15@gated-at.bofh.it> |
| In reply to | #1180528 |
Cc: Peter Zijlstra <peterz@infradead.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: linux-arch@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Vineet Gupta <vgupta@synopsys.com> --- arch/arc/include/asm/atomic.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h index 03484cb4d16d..fab27dbc562b 100644 --- a/arch/arc/include/asm/atomic.h +++ b/arch/arc/include/asm/atomic.h @@ -141,10 +141,19 @@ static inline int atomic_##op##_return(int i, atomic_t *v) \ ATOMIC_OP(op, c_op, asm_op) \ ATOMIC_OP_RETURN(op, c_op, asm_op) +/* atomic_add(), atomic_add_return() */ ATOMIC_OPS(add, +=, add) + +/* atomic_sub(), atomic_sub_return() */ ATOMIC_OPS(sub, -=, sub) + +/* atomic_and() */ ATOMIC_OP(and, &=, and) +#define ARCH_HAS_ATOMIC_OR +/* atomic_or() */ +ATOMIC_OP(or, |=, or) + #define atomic_clear_mask(mask, v) atomic_and(~(mask), (v)) #undef ATOMIC_OPS -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2015-07-09 10:20 +0200 |
| Subject | [PATCH 1/3] asm-generic/atomic.h: ARCH_HAS_ATOMIC_OR -> CONFIG_ARCH_HAS_ATOMIC_OR |
| Message-ID | <pKfdM-6cK-25@gated-at.bofh.it> |
| In reply to | #1180528 |
Since this is not backed by a Kconfig option, remove CONFIG_ prefix
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: linux-arch@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
---
include/asm-generic/atomic.h | 2 +-
include/linux/atomic.h | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
index 1973ad2b13f4..1a1cdab6e702 100644
--- a/include/asm-generic/atomic.h
+++ b/include/asm-generic/atomic.h
@@ -104,7 +104,7 @@ ATOMIC_OP(and, &)
#endif
#ifndef atomic_set_mask
-#define CONFIG_ARCH_HAS_ATOMIC_OR
+#define ARCH_HAS_ATOMIC_OR
ATOMIC_OP(or, |)
#define atomic_set_mask(i, v) atomic_or((i), (v))
#endif
diff --git a/include/linux/atomic.h b/include/linux/atomic.h
index 5b08a8540ecf..195881eec33e 100644
--- a/include/linux/atomic.h
+++ b/include/linux/atomic.h
@@ -111,7 +111,7 @@ static inline int atomic_dec_if_positive(atomic_t *v)
}
#endif
-#ifndef CONFIG_ARCH_HAS_ATOMIC_OR
+#ifndef ARCH_HAS_ATOMIC_OR
static inline void atomic_or(int i, atomic_t *v)
{
int old;
@@ -122,7 +122,7 @@ static inline void atomic_or(int i, atomic_t *v)
new = old | i;
} while (atomic_cmpxchg(v, old, new) != old);
}
-#endif /* #ifndef CONFIG_ARCH_HAS_ATOMIC_OR */
+#endif /* #ifndef ARCH_HAS_ATOMIC_OR */
#include <asm-generic/atomic-long.h>
#ifdef CONFIG_GENERIC_ATOMIC64
--
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/
[toc] | [prev] | [next] | [standalone]
| From | Peter Zijlstra <peterz@infradead.org> |
|---|---|
| Date | 2015-07-09 14:40 +0200 |
| Message-ID | <pKjhp-9T-35@gated-at.bofh.it> |
| In reply to | #1180528 |
I see what you did there.. gimme a few more hours, I'll finish what I have and stuff it through the build bot. I've just not managed to finish tile, but did do frv this time. -- 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/
[toc] | [prev] | [next] | [standalone]
| From | Vineet Gupta <Vineet.Gupta1@synopsys.com> |
|---|---|
| Date | 2015-07-09 15:10 +0200 |
| Message-ID | <pKjKr-Ae-49@gated-at.bofh.it> |
| In reply to | #1180684 |
On Thursday 09 July 2015 06:01 PM, Peter Zijlstra wrote: > I've just not managed to finish tile, but did do frv this time. Not sure what you mean - are you also doing a similar series which extends atomic_or to other arches too which will probably we simpler now given ur earlier macro-fication of this code ! -vineet -- 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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web