um: "borrow" cmpxchg from x86 tree in UML
[email protected]
maintainerPATCH 1/1 um: "borrow" cmpxchg from x86 tree in UML
From: Anton Ivanov <[email protected]>
UML was falling back to asm-generic cmpxchg which emulates atomic behaviour by turning irqs on/off. On UML this means turning on/off signals for each cmpxchg which is expensive.
--- arch/um/include/asm/cmpxchg-x86.h | 1 + arch/um/include/asm/cmpxchg.h | 13 +++++++++++++ arch/um/include/asm/cmpxchg_32.h | 1 + arch/um/include/asm/cmpxchg_64.h | 1 + 4 files changed, 16 insertions(+) create mode 120000 arch/um/include/asm/cmpxchg-x86.h create mode 100644 arch/um/include/asm/cmpxchg.h create mode 120000 arch/um/include/asm/cmpxchg_32.h create mode 120000 arch/um/include/asm/cmpxchg_64.h
arch/um/include/asm/cmpxchg-x86.h new file +1 -0
@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg.h
arch/um/include/asm/cmpxchg.h new file +13 -0
@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_UM_CMPXCHG_H +#define _ASM_UM_CMPXCHG_H + +#ifdef CONFIG_64BIT +#undef CONFIG_X86_32 +#else +#define CONFIG_X86_32 1 +#endif + +#include <asm/cmpxchg-x86.h> + +#endif
arch/um/include/asm/cmpxchg_32.h new file +1 -0
@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg_32.h
arch/um/include/asm/cmpxchg_64.h new file +1 -0
@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg_64.h
Signature · 7 lines
2.20.1 _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Anton Ivanov
maintainerQuoted 59 lines · On 13/11/2020 11:54, [email protected] wrote:
From: Anton Ivanov <[email protected]>
UML was falling back to asm-generic cmpxchg which emulates atomic behaviour by turning irqs on/off. On UML this means turning on/off signals for each cmpxchg which is expensive.
Signed-off-by Anton Ivanov <[email protected]>--- arch/um/include/asm/cmpxchg-x86.h | 1 + arch/um/include/asm/cmpxchg.h | 13 +++++++++++++ arch/um/include/asm/cmpxchg_32.h | 1 + arch/um/include/asm/cmpxchg_64.h | 1 + 4 files changed, 16 insertions(+)create mode 120000
arch/um/include/asm/cmpxchg-x86.hcreate mode 100644arch/um/include/asm/cmpxchg.hcreate mode 120000arch/um/include/asm/cmpxchg_32.hcreate mode 120000arch/um/include/asm/cmpxchg_64.harch/um/include/asm/cmpxchg-x86.h new file +1
-0@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg.harch/um/include/asm/cmpxchg.h new file +13
-0@@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_UM_CMPXCHG_H +#define _ASM_UM_CMPXCHG_H + +#ifdef CONFIG_64BIT +#undef CONFIG_X86_32 +#else +#define CONFIG_X86_32 1 +#endif + +#include <asm/cmpxchg-x86.h> + +#endif arch/um/include/asm/cmpxchg_32.h new file +1
-0@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg_32.harch/um/include/asm/cmpxchg_64.h new file +0
-0
arch/um/include/asm/cmpxchg_64.h line 1
Quoted 2 lines
arch/um/include/asm/cmpxchg_64.h new file +1
-0@@ -0,0 +1 @@ +../../../x86/include/asm/cmpxchg_64.h
I think that was it. Or to be more exact, I hope that was it.
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
So to recap:
string.hxor.hfutex.hcmpxchg.hatomic.h
Brgds,
Signature · 9 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/ _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Johannes Berg
maintainerQuoted 6 lines · Anton Ivanov
I think that was it. Or to be more exact, I hope that was it.
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
It seems that word-at-a-time.h with CONFIG_DCACHE_WORD_ACCESS might be worthwhile as well?
Also perhaps bug.h; there are a lot of BUG_ON/WARN_ON and similar things, and especially the _ONCE part looks better there?
ftrace is probably not worth the effort ...
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Anton Ivanov
maintainerQuoted 8 lines · Johannes Berg
Quoted 5 lines · Anton Ivanov
I think that was it. Or to be more exact, I hope that was it.
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
It seems that
word-at-a-time.hwithCONFIG_DCACHE_WORD_ACCESSmight be worthwhile as well?
I tried it. It had some references to exception handling which are not present in UML so I dropped it for now.
We may get it to work, but it will take some effort. I think it also had alternatives in the assembly parts so that means similar problems to using x86 memcpy and x86 memmove.
Quoted 3 lines
Also perhaps
bug.h; there are a lot of BUG_ON/WARN_ON and similar things, and especially the_ONCEpart looks better there?
There are some advantages there, but the difference between x86 and generic does not look to be as drastic as atomics or futex.
We can pull it in.
Quoted 2 lines
ftrace is probably not worth the effort ...
Concur.
Quoted 3 lines
johannes
Brgds,
Signature · 9 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/ _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Johannes Berg
maintainerQuoted 4 lines · Anton Ivanov
Quoted 3 lines · Johannes Berg
Quoted 2 lines · Anton Ivanov
I think that was it. Or to be more exact, I hope that was it.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
It seems that
word-at-a-time.hwithCONFIG_DCACHE_WORD_ACCESSmight be worthwhile as well?I tried it. It had some references to exception handling which are not present in UML so I dropped it for now.
Oh, right ... I played with that once for something else and couldn't figure out how to port it. Oh well.
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Anton Ivanov
maintainerQuoted 8 lines · Johannes Berg
Quoted 7 lines · Anton Ivanov
Quoted 6 lines · Johannes Berg
Quoted 5 lines · Anton Ivanov
I think that was it. Or to be more exact, I hope that was it.
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
Quoted 6 lines
Quoted 4 lines
Quoted 2 lines
It seems that
word-at-a-time.hwithCONFIG_DCACHE_WORD_ACCESSmight be worthwhile as well?I tried it. It had some references to exception handling which are not present in UML so I dropped it for now.
Oh, right ... I played with that once for something else and couldn't figure out how to port it. Oh well.
I did only the low hanging fruit this time :)
This one looked like it needs figuring out a porting strategy so I skipped it.
Quoted 8 lines
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
Signature · 9 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/ _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um
Anton Ivanov
maintainerQuoted 16 lines · Johannes Berg
Quoted 6 lines · Anton Ivanov
I think that was it. Or to be more exact, I hope that was it.
I went a few times through asm-generic and that looks like all the bits which are worth implementing for a uniprocessor architecture as a replacement for their generic equivalents.
It seems that
word-at-a-time.hwithCONFIG_DCACHE_WORD_ACCESSmight be worthwhile as well?Also perhaps
bug.h; there are a lot of BUG_ON/WARN_ON and similar things, and especially the_ONCEpart looks better there?ftrace is probably not worth the effort ...
Quoted 8 lines
johannes
_______________________________________________
linux-um mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-um
There is one more which makes for a surprisingly big difference - a couple of more % on find /usr -type f -exec cat {} > /dev/null \;
bitops.h
Actually, it is not that surprising, fs and memory which are exercised this way have bitops all over the place.
Patch coming shortly.
I also have a patch to switch to proper cmpxchg in the futex/uaccess, but that has to go in after everything else. If atomics and cmpxchg have not gone in, it actually does more harm than good.
A.
Signature · 8 lines
Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/ _______________________________________________ linux-um mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-um