aboutsummaryrefslogtreecommitdiffstats
path: root/lib/raid6
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:03:41 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2013-09-10 16:03:41 -0400
commit4d7696f1b05f4aeb586c74868fe3da2731daca4b (patch)
treedd6cf4d41df2c0a1f52a85a3f8b8af5a9ebdeb5d /lib/raid6
parentb05430fc9341fea7a6228a3611c850a476809596 (diff)
parentbfc90cb0936f5b972706625f38f72c7cb726c20a (diff)
Merge tag 'md/3.12' of git://neil.brown.name/md
Pull md update from Neil Brown: "Headline item is multithreading for RAID5 so that more IO/sec can be supported on fast (SSD) devices. Also TILE-Gx SIMD suppor for RAID6 calculations and an assortment of bug fixes" * tag 'md/3.12' of git://neil.brown.name/md: raid5: only wakeup necessary threads md/raid5: flush out all pending requests before proceeding with reshape. md/raid5: use seqcount to protect access to shape in make_request. raid5: sysfs entry to control worker thread number raid5: offload stripe handle to workqueue raid5: fix stripe release order raid5: make release_stripe lockless md: avoid deadlock when dirty buffers during md_stop. md: Don't test all of mddev->flags at once. md: Fix apparent cut-and-paste error in super_90_validate raid6/test: replace echo -e with printf RAID: add tilegx SIMD implementation of raid6 md: fix safe_mode buglet. md: don't call md_allow_write in get_bitmap_file.
Diffstat (limited to 'lib/raid6')
-rw-r--r--lib/raid6/Makefile6
-rw-r--r--lib/raid6/algos.c3
-rw-r--r--lib/raid6/test/Makefile9
-rw-r--r--lib/raid6/tilegx.uc86
4 files changed, 103 insertions, 1 deletions
diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile
index b4625787c7ee..c7dab0645554 100644
--- a/lib/raid6/Makefile
+++ b/lib/raid6/Makefile
@@ -6,6 +6,7 @@ raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \
6raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o 6raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o
7raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o 7raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o
8raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o 8raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o
9raid6_pq-$(CONFIG_TILEGX) += tilegx8.o
9 10
10hostprogs-y += mktables 11hostprogs-y += mktables
11 12
@@ -110,6 +111,11 @@ $(obj)/neon8.c: UNROLL := 8
110$(obj)/neon8.c: $(src)/neon.uc $(src)/unroll.awk FORCE 111$(obj)/neon8.c: $(src)/neon.uc $(src)/unroll.awk FORCE
111 $(call if_changed,unroll) 112 $(call if_changed,unroll)
112 113
114targets += tilegx8.c
115$(obj)/tilegx8.c: UNROLL := 8
116$(obj)/tilegx8.c: $(src)/tilegx.uc $(src)/unroll.awk FORCE
117 $(call if_changed,unroll)
118
113quiet_cmd_mktable = TABLE $@ 119quiet_cmd_mktable = TABLE $@
114 cmd_mktable = $(obj)/mktables > $@ || ( rm -f $@ && exit 1 ) 120 cmd_mktable = $(obj)/mktables > $@ || ( rm -f $@ && exit 1 )
115 121
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c
index 74e6f5629dbc..f0b1aa3586d1 100644
--- a/lib/raid6/algos.c
+++ b/lib/raid6/algos.c
@@ -66,6 +66,9 @@ const struct raid6_calls * const raid6_algos[] = {
66 &raid6_altivec4, 66 &raid6_altivec4,
67 &raid6_altivec8, 67 &raid6_altivec8,
68#endif 68#endif
69#if defined(CONFIG_TILEGX)
70 &raid6_tilegx8,
71#endif
69 &raid6_intx1, 72 &raid6_intx1,
70 &raid6_intx2, 73 &raid6_intx2,
71 &raid6_intx4, 74 &raid6_intx4,
diff --git a/lib/raid6/test/Makefile b/lib/raid6/test/Makefile
index 28afa1a06e03..29090f3db677 100644
--- a/lib/raid6/test/Makefile
+++ b/lib/raid6/test/Makefile
@@ -40,13 +40,16 @@ else ifeq ($(HAS_NEON),yes)
40 OBJS += neon.o neon1.o neon2.o neon4.o neon8.o 40 OBJS += neon.o neon1.o neon2.o neon4.o neon8.o
41 CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1 41 CFLAGS += -DCONFIG_KERNEL_MODE_NEON=1
42else 42else
43 HAS_ALTIVEC := $(shell echo -e '\#include <altivec.h>\nvector int a;' |\ 43 HAS_ALTIVEC := $(shell printf '\#include <altivec.h>\nvector int a;\n' |\
44 gcc -c -x c - >&/dev/null && \ 44 gcc -c -x c - >&/dev/null && \
45 rm ./-.o && echo yes) 45 rm ./-.o && echo yes)
46 ifeq ($(HAS_ALTIVEC),yes) 46 ifeq ($(HAS_ALTIVEC),yes)
47 OBJS += altivec1.o altivec2.o altivec4.o altivec8.o 47 OBJS += altivec1.o altivec2.o altivec4.o altivec8.o
48 endif 48 endif
49endif 49endif
50ifeq ($(ARCH),tilegx)
51OBJS += tilegx8.o
52endif
50 53
51.c.o: 54.c.o:
52 $(CC) $(CFLAGS) -c -o $@ $< 55 $(CC) $(CFLAGS) -c -o $@ $<
@@ -109,11 +112,15 @@ int16.c: int.uc ../unroll.awk
109int32.c: int.uc ../unroll.awk 112int32.c: int.uc ../unroll.awk
110 $(AWK) ../unroll.awk -vN=32 < int.uc > $@ 113 $(AWK) ../unroll.awk -vN=32 < int.uc > $@
111 114
115tilegx8.c: tilegx.uc ../unroll.awk
116 $(AWK) ../unroll.awk -vN=8 < tilegx.uc > $@
117
112tables.c: mktables 118tables.c: mktables
113 ./mktables > tables.c 119 ./mktables > tables.c
114 120
115clean: 121clean:
116 rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c neon*.c tables.c raid6test 122 rm -f *.o *.a mktables mktables.c *.uc int*.c altivec*.c neon*.c tables.c raid6test
123 rm -f tilegx*.c
117 124
118spotless: clean 125spotless: clean
119 rm -f *~ 126 rm -f *~
diff --git a/lib/raid6/tilegx.uc b/lib/raid6/tilegx.uc
new file mode 100644
index 000000000000..e7c29459cbcd
--- /dev/null
+++ b/lib/raid6/tilegx.uc
@@ -0,0 +1,86 @@
1/* -*- linux-c -*- ------------------------------------------------------- *
2 *
3 * Copyright 2002 H. Peter Anvin - All Rights Reserved
4 * Copyright 2012 Tilera Corporation - All Rights Reserved
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, Inc., 53 Temple Place Ste 330,
9 * Boston MA 02111-1307, USA; either version 2 of the License, or
10 * (at your option) any later version; incorporated herein by reference.
11 *
12 * ----------------------------------------------------------------------- */
13
14/*
15 * tilegx$#.c
16 *
17 * $#-way unrolled TILE-Gx SIMD for RAID-6 math.
18 *
19 * This file is postprocessed using unroll.awk.
20 *
21 */
22
23#include <linux/raid/pq.h>
24
25/* Create 8 byte copies of constant byte */
26# define NBYTES(x) (__insn_v1addi(0, x))
27# define NSIZE 8
28
29/*
30 * The SHLBYTE() operation shifts each byte left by 1, *not*
31 * rolling over into the next byte
32 */
33static inline __attribute_const__ u64 SHLBYTE(u64 v)
34{
35 /* Vector One Byte Shift Left Immediate. */
36 return __insn_v1shli(v, 1);
37}
38
39/*
40 * The MASK() operation returns 0xFF in any byte for which the high
41 * bit is 1, 0x00 for any byte for which the high bit is 0.
42 */
43static inline __attribute_const__ u64 MASK(u64 v)
44{
45 /* Vector One Byte Shift Right Signed Immediate. */
46 return __insn_v1shrsi(v, 7);
47}
48
49
50void raid6_tilegx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
51{
52 u8 **dptr = (u8 **)ptrs;
53 u64 *p, *q;
54 int d, z, z0;
55
56 u64 wd$$, wq$$, wp$$, w1$$, w2$$;
57 u64 x1d = NBYTES(0x1d);
58 u64 * z0ptr;
59
60 z0 = disks - 3; /* Highest data disk */
61 p = (u64 *)dptr[z0+1]; /* XOR parity */
62 q = (u64 *)dptr[z0+2]; /* RS syndrome */
63
64 z0ptr = (u64 *)&dptr[z0][0];
65 for ( d = 0 ; d < bytes ; d += NSIZE*$# ) {
66 wq$$ = wp$$ = *z0ptr++;
67 for ( z = z0-1 ; z >= 0 ; z-- ) {
68 wd$$ = *(u64 *)&dptr[z][d+$$*NSIZE];
69 wp$$ = wp$$ ^ wd$$;
70 w2$$ = MASK(wq$$);
71 w1$$ = SHLBYTE(wq$$);
72 w2$$ = w2$$ & x1d;
73 w1$$ = w1$$ ^ w2$$;
74 wq$$ = w1$$ ^ wd$$;
75 }
76 *p++ = wp$$;
77 *q++ = wq$$;
78 }
79}
80
81const struct raid6_calls raid6_tilegx$# = {
82 raid6_tilegx$#_gen_syndrome,
83 NULL,
84 "tilegx$#",
85 0
86};