diff options
author | Ralf Baechle <ralf@linux-mips.org> | 2015-09-29 06:19:48 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-10-26 04:49:43 -0400 |
commit | 1ee3630a3e57f38f688a6f0a5f9edbd8a0d7201f (patch) | |
tree | 3326b59ffb2650bff622642700981bf5541a1b04 | |
parent | d478b088a2f74fc8f34af7ceed86fa7640ca8610 (diff) |
MIPS: Use ARCH_USE_BUILTIN_BSWAP.
ARCH_USE_BUILTIN_BSWAP will use __builtin_bswap16(), __builtin_bswap32()
and __builtin_bswap64() where available. This allows better instruction
scheduling. On pre-R2 processors it will result in 32 bit and 64 bit
swapping being performed in a call to a __bswapsi2() rsp. __bswapdi2()
functions, so we add these, too.
For a 4.2 kernel with GCC 4.9 this yields the following kernel sizes:
text data bss dec hex filename
3996071 155804 88992 4240867 40b5e3 vmlinux ip22 baseline
3985687 159900 88992 4234579 409d53 vmlinux ip22 + bswap patch
6913157 378552 251024 7542733 7317cd vmlinux ip27 baseline
6878581 378552 251024 7508157 7290bd vmlinux ip27 + bswap patch
5773777 268752 187424 6229953 5f0fc1 vmlinux malta baseline
5773401 268752 187424 6229577 5f0e49 vmlinux malta + bswap patch
Presumably the code size improvments yield better cache hit rate thus
better performance compensating for the extra function call but this
will still need to be benchmarked.
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/Kconfig | 1 | ||||
-rw-r--r-- | arch/mips/lib/Makefile | 2 | ||||
-rw-r--r-- | arch/mips/lib/bswapdi.c | 15 | ||||
-rw-r--r-- | arch/mips/lib/bswapsi.c | 11 |
4 files changed, 28 insertions, 1 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index e3aa5b0b4ef1..c08e7016c77a 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -5,6 +5,7 @@ config MIPS | |||
5 | select ARCH_MIGHT_HAVE_PC_PARPORT | 5 | select ARCH_MIGHT_HAVE_PC_PARPORT |
6 | select ARCH_MIGHT_HAVE_PC_SERIO | 6 | select ARCH_MIGHT_HAVE_PC_SERIO |
7 | select ARCH_USE_CMPXCHG_LOCKREF if 64BIT | 7 | select ARCH_USE_CMPXCHG_LOCKREF if 64BIT |
8 | select ARCH_USE_BUILTIN_BSWAP | ||
8 | select HAVE_CONTEXT_TRACKING | 9 | select HAVE_CONTEXT_TRACKING |
9 | select HAVE_GENERIC_DMA_COHERENT | 10 | select HAVE_GENERIC_DMA_COHERENT |
10 | select HAVE_IDE | 11 | select HAVE_IDE |
diff --git a/arch/mips/lib/Makefile b/arch/mips/lib/Makefile index 1e9e900cd3c3..0344e575f522 100644 --- a/arch/mips/lib/Makefile +++ b/arch/mips/lib/Makefile | |||
@@ -15,4 +15,4 @@ obj-$(CONFIG_CPU_R3000) += r3k_dump_tlb.o | |||
15 | obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o | 15 | obj-$(CONFIG_CPU_TX39XX) += r3k_dump_tlb.o |
16 | 16 | ||
17 | # libgcc-style stuff needed in the kernel | 17 | # libgcc-style stuff needed in the kernel |
18 | obj-y += ashldi3.o ashrdi3.o cmpdi2.o lshrdi3.o ucmpdi2.o | 18 | obj-y += ashldi3.o ashrdi3.o bswapsi.o bswapdi.o cmpdi2.o lshrdi3.o ucmpdi2.o |
diff --git a/arch/mips/lib/bswapdi.c b/arch/mips/lib/bswapdi.c new file mode 100644 index 000000000000..77e5f9c1f005 --- /dev/null +++ b/arch/mips/lib/bswapdi.c | |||
@@ -0,0 +1,15 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | unsigned long long __bswapdi2(unsigned long long u) | ||
4 | { | ||
5 | return (((u) & 0xff00000000000000ull) >> 56) | | ||
6 | (((u) & 0x00ff000000000000ull) >> 40) | | ||
7 | (((u) & 0x0000ff0000000000ull) >> 24) | | ||
8 | (((u) & 0x000000ff00000000ull) >> 8) | | ||
9 | (((u) & 0x00000000ff000000ull) << 8) | | ||
10 | (((u) & 0x0000000000ff0000ull) << 24) | | ||
11 | (((u) & 0x000000000000ff00ull) << 40) | | ||
12 | (((u) & 0x00000000000000ffull) << 56); | ||
13 | } | ||
14 | |||
15 | EXPORT_SYMBOL(__bswapdi2); | ||
diff --git a/arch/mips/lib/bswapsi.c b/arch/mips/lib/bswapsi.c new file mode 100644 index 000000000000..2b302ff121d2 --- /dev/null +++ b/arch/mips/lib/bswapsi.c | |||
@@ -0,0 +1,11 @@ | |||
1 | #include <linux/module.h> | ||
2 | |||
3 | unsigned int __bswapsi2(unsigned int u) | ||
4 | { | ||
5 | return (((u) & 0xff000000) >> 24) | | ||
6 | (((u) & 0x00ff0000) >> 8) | | ||
7 | (((u) & 0x0000ff00) << 8) | | ||
8 | (((u) & 0x000000ff) << 24); | ||
9 | } | ||
10 | |||
11 | EXPORT_SYMBOL(__bswapsi2); | ||