diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-18 12:32:44 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-12-18 12:32:44 -0500 |
| commit | ea88eeac0cb8328014b53d80ca631e8dc0dc18dc (patch) | |
| tree | de605c1d0e7ab1e342eedad47c56061b65a6b790 /lib | |
| parent | 848b81415c42ff3dc9a4204749087b015c37ef66 (diff) | |
| parent | a9add5d92b64ea57fb4c3b557c3891cdeb15fa0c (diff) | |
Merge tag 'md-3.8' of git://neil.brown.name/md
Pull md update from Neil Brown:
"Mostly just little fixes. Probably biggest part is AVX accelerated
RAID6 calculations."
* tag 'md-3.8' of git://neil.brown.name/md:
md/raid5: add blktrace calls
md/raid5: use async_tx_quiesce() instead of open-coding it.
md: Use ->curr_resync as last completed request when cleanly aborting resync.
lib/raid6: build proper files on corresponding arch
lib/raid6: Add AVX2 optimized gen_syndrome functions
lib/raid6: Add AVX2 optimized recovery functions
md: Update checkpoint of resync/recovery based on time.
md:Add place to update ->recovery_cp.
md.c: re-indent various 'switch' statements.
md: close race between removing and adding a device.
md: removed unused variable in calc_sb_1_csm.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/raid6/Makefile | 9 | ||||
| -rw-r--r-- | lib/raid6/algos.c | 12 | ||||
| -rw-r--r-- | lib/raid6/altivec.uc | 3 | ||||
| -rw-r--r-- | lib/raid6/avx2.c | 251 | ||||
| -rw-r--r-- | lib/raid6/mmx.c | 2 | ||||
| -rw-r--r-- | lib/raid6/recov_avx2.c | 323 | ||||
| -rw-r--r-- | lib/raid6/recov_ssse3.c | 4 | ||||
| -rw-r--r-- | lib/raid6/sse1.c | 2 | ||||
| -rw-r--r-- | lib/raid6/sse2.c | 8 | ||||
| -rw-r--r-- | lib/raid6/test/Makefile | 29 | ||||
| -rw-r--r-- | lib/raid6/x86.h | 14 |
11 files changed, 631 insertions, 26 deletions
diff --git a/lib/raid6/Makefile b/lib/raid6/Makefile index de06dfe165b8..9f7c184725d7 100644 --- a/lib/raid6/Makefile +++ b/lib/raid6/Makefile | |||
| @@ -1,8 +1,11 @@ | |||
| 1 | obj-$(CONFIG_RAID6_PQ) += raid6_pq.o | 1 | obj-$(CONFIG_RAID6_PQ) += raid6_pq.o |
| 2 | 2 | ||
| 3 | raid6_pq-y += algos.o recov.o recov_ssse3.o tables.o int1.o int2.o int4.o \ | 3 | raid6_pq-y += algos.o recov.o tables.o int1.o int2.o int4.o \ |
| 4 | int8.o int16.o int32.o altivec1.o altivec2.o altivec4.o \ | 4 | int8.o int16.o int32.o |
| 5 | altivec8.o mmx.o sse1.o sse2.o | 5 | |
| 6 | raid6_pq-$(CONFIG_X86) += recov_ssse3.o recov_avx2.o mmx.o sse1.o sse2.o avx2.o | ||
| 7 | raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o | ||
| 8 | |||
| 6 | hostprogs-y += mktables | 9 | hostprogs-y += mktables |
| 7 | 10 | ||
| 8 | quiet_cmd_unroll = UNROLL $@ | 11 | quiet_cmd_unroll = UNROLL $@ |
diff --git a/lib/raid6/algos.c b/lib/raid6/algos.c index 589f5f50ad2e..6d7316fe9f30 100644 --- a/lib/raid6/algos.c +++ b/lib/raid6/algos.c | |||
| @@ -45,11 +45,20 @@ const struct raid6_calls * const raid6_algos[] = { | |||
| 45 | &raid6_sse1x2, | 45 | &raid6_sse1x2, |
| 46 | &raid6_sse2x1, | 46 | &raid6_sse2x1, |
| 47 | &raid6_sse2x2, | 47 | &raid6_sse2x2, |
| 48 | #ifdef CONFIG_AS_AVX2 | ||
| 49 | &raid6_avx2x1, | ||
| 50 | &raid6_avx2x2, | ||
| 51 | #endif | ||
| 48 | #endif | 52 | #endif |
| 49 | #if defined(__x86_64__) && !defined(__arch_um__) | 53 | #if defined(__x86_64__) && !defined(__arch_um__) |
| 50 | &raid6_sse2x1, | 54 | &raid6_sse2x1, |
| 51 | &raid6_sse2x2, | 55 | &raid6_sse2x2, |
| 52 | &raid6_sse2x4, | 56 | &raid6_sse2x4, |
| 57 | #ifdef CONFIG_AS_AVX2 | ||
| 58 | &raid6_avx2x1, | ||
| 59 | &raid6_avx2x2, | ||
| 60 | &raid6_avx2x4, | ||
| 61 | #endif | ||
| 53 | #endif | 62 | #endif |
| 54 | #ifdef CONFIG_ALTIVEC | 63 | #ifdef CONFIG_ALTIVEC |
| 55 | &raid6_altivec1, | 64 | &raid6_altivec1, |
| @@ -72,6 +81,9 @@ EXPORT_SYMBOL_GPL(raid6_datap_recov); | |||
| 72 | 81 | ||
| 73 | const struct raid6_recov_calls *const raid6_recov_algos[] = { | 82 | const struct raid6_recov_calls *const raid6_recov_algos[] = { |
| 74 | #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) | 83 | #if (defined(__i386__) || defined(__x86_64__)) && !defined(__arch_um__) |
| 84 | #ifdef CONFIG_AS_AVX2 | ||
| 85 | &raid6_recov_avx2, | ||
| 86 | #endif | ||
| 75 | &raid6_recov_ssse3, | 87 | &raid6_recov_ssse3, |
| 76 | #endif | 88 | #endif |
| 77 | &raid6_recov_intx1, | 89 | &raid6_recov_intx1, |
diff --git a/lib/raid6/altivec.uc b/lib/raid6/altivec.uc index b71012b756f4..7cc12b532e95 100644 --- a/lib/raid6/altivec.uc +++ b/lib/raid6/altivec.uc | |||
| @@ -24,13 +24,10 @@ | |||
| 24 | 24 | ||
| 25 | #include <linux/raid/pq.h> | 25 | #include <linux/raid/pq.h> |
| 26 | 26 | ||
| 27 | #ifdef CONFIG_ALTIVEC | ||
| 28 | |||
| 29 | #include <altivec.h> | 27 | #include <altivec.h> |
| 30 | #ifdef __KERNEL__ | 28 | #ifdef __KERNEL__ |
| 31 | # include <asm/cputable.h> | 29 | # include <asm/cputable.h> |
| 32 | # include <asm/switch_to.h> | 30 | # include <asm/switch_to.h> |
| 33 | #endif | ||
| 34 | 31 | ||
| 35 | /* | 32 | /* |
| 36 | * This is the C data type to use. We use a vector of | 33 | * This is the C data type to use. We use a vector of |
diff --git a/lib/raid6/avx2.c b/lib/raid6/avx2.c new file mode 100644 index 000000000000..bc3b1dd436eb --- /dev/null +++ b/lib/raid6/avx2.c | |||
| @@ -0,0 +1,251 @@ | |||
| 1 | /* -*- linux-c -*- ------------------------------------------------------- * | ||
| 2 | * | ||
| 3 | * Copyright (C) 2012 Intel Corporation | ||
| 4 | * Author: Yuanhan Liu <yuanhan.liu@linux.intel.com> | ||
| 5 | * | ||
| 6 | * Based on sse2.c: Copyright 2002 H. Peter Anvin - All Rights Reserved | ||
| 7 | * | ||
| 8 | * | ||
| 9 | * This program is free software; you can redistribute it and/or modify | ||
| 10 | * it under the terms of the GNU General Public License as published by | ||
| 11 | * the Free Software Foundation, Inc., 53 Temple Place Ste 330, | ||
| 12 | * Boston MA 02111-1307, USA; either version 2 of the License, or | ||
| 13 | * (at your option) any later version; incorporated herein by reference. | ||
| 14 | * | ||
| 15 | * ----------------------------------------------------------------------- */ | ||
| 16 | |||
| 17 | /* | ||
| 18 | * AVX2 implementation of RAID-6 syndrome functions | ||
| 19 | * | ||
| 20 | */ | ||
| 21 | |||
| 22 | #ifdef CONFIG_AS_AVX2 | ||
| 23 | |||
| 24 | #include <linux/raid/pq.h> | ||
| 25 | #include "x86.h" | ||
| 26 | |||
| 27 | static const struct raid6_avx2_constants { | ||
| 28 | u64 x1d[4]; | ||
| 29 | } raid6_avx2_constants __aligned(32) = { | ||
| 30 | { 0x1d1d1d1d1d1d1d1dULL, 0x1d1d1d1d1d1d1d1dULL, | ||
| 31 | 0x1d1d1d1d1d1d1d1dULL, 0x1d1d1d1d1d1d1d1dULL,}, | ||
| 32 | }; | ||
| 33 | |||
| 34 | static int raid6_have_avx2(void) | ||
| 35 | { | ||
| 36 | return boot_cpu_has(X86_FEATURE_AVX2) && boot_cpu_has(X86_FEATURE_AVX); | ||
| 37 | } | ||
| 38 | |||
| 39 | /* | ||
| 40 | * Plain AVX2 implementation | ||
| 41 | */ | ||
| 42 | static void raid6_avx21_gen_syndrome(int disks, size_t bytes, void **ptrs) | ||
| 43 | { | ||
| 44 | u8 **dptr = (u8 **)ptrs; | ||
| 45 | u8 *p, *q; | ||
| 46 | int d, z, z0; | ||
| 47 | |||
| 48 | z0 = disks - 3; /* Highest data disk */ | ||
| 49 | p = dptr[z0+1]; /* XOR parity */ | ||
| 50 | q = dptr[z0+2]; /* RS syndrome */ | ||
| 51 | |||
| 52 | kernel_fpu_begin(); | ||
| 53 | |||
| 54 | asm volatile("vmovdqa %0,%%ymm0" : : "m" (raid6_avx2_constants.x1d[0])); | ||
| 55 | asm volatile("vpxor %ymm3,%ymm3,%ymm3"); /* Zero temp */ | ||
| 56 | |||
| 57 | for (d = 0; d < bytes; d += 32) { | ||
| 58 | asm volatile("prefetchnta %0" : : "m" (dptr[z0][d])); | ||
| 59 | asm volatile("vmovdqa %0,%%ymm2" : : "m" (dptr[z0][d]));/* P[0] */ | ||
| 60 | asm volatile("prefetchnta %0" : : "m" (dptr[z0-1][d])); | ||
| 61 | asm volatile("vmovdqa %ymm2,%ymm4");/* Q[0] */ | ||
| 62 | asm volatile("vmovdqa %0,%%ymm6" : : "m" (dptr[z0-1][d])); | ||
| 63 | for (z = z0-2; z >= 0; z--) { | ||
| 64 | asm volatile("prefetchnta %0" : : "m" (dptr[z][d])); | ||
| 65 | asm volatile("vpcmpgtb %ymm4,%ymm3,%ymm5"); | ||
| 66 | asm volatile("vpaddb %ymm4,%ymm4,%ymm4"); | ||
| 67 | asm volatile("vpand %ymm0,%ymm5,%ymm5"); | ||
| 68 | asm volatile("vpxor %ymm5,%ymm4,%ymm4"); | ||
| 69 | asm volatile("vpxor %ymm6,%ymm2,%ymm2"); | ||
| 70 | asm volatile("vpxor %ymm6,%ymm4,%ymm4"); | ||
| 71 | asm volatile("vmovdqa %0,%%ymm6" : : "m" (dptr[z][d])); | ||
| 72 | } | ||
| 73 | asm volatile("vpcmpgtb %ymm4,%ymm3,%ymm5"); | ||
| 74 | asm volatile("vpaddb %ymm4,%ymm4,%ymm4"); | ||
| 75 | asm volatile("vpand %ymm0,%ymm5,%ymm5"); | ||
| 76 | asm volatile("vpxor %ymm5,%ymm4,%ymm4"); | ||
| 77 | asm volatile("vpxor %ymm6,%ymm2,%ymm2"); | ||
| 78 | asm volatile("vpxor %ymm6,%ymm4,%ymm4"); | ||
| 79 | |||
| 80 | asm volatile("vmovntdq %%ymm2,%0" : "=m" (p[d])); | ||
| 81 | asm volatile("vpxor %ymm2,%ymm2,%ymm2"); | ||
| 82 | asm volatile("vmovntdq %%ymm4,%0" : "=m" (q[d])); | ||
| 83 | asm volatile("vpxor %ymm4,%ymm4,%ymm4"); | ||
| 84 | } | ||
| 85 | |||
| 86 | asm volatile("sfence" : : : "memory"); | ||
| 87 | kernel_fpu_end(); | ||
| 88 | } | ||
| 89 | |||
| 90 | const struct raid6_calls raid6_avx2x1 = { | ||
| 91 | raid6_avx21_gen_syndrome, | ||
| 92 | raid6_have_avx2, | ||
| 93 | "avx2x1", | ||
| 94 | 1 /* Has cache hints */ | ||
| 95 | }; | ||
| 96 | |||
| 97 | /* | ||
| 98 | * Unrolled-by-2 AVX2 implementation | ||
| 99 | */ | ||
| 100 | static void raid6_avx22_gen_syndrome(int disks, size_t bytes, void **ptrs) | ||
| 101 | { | ||
| 102 | u8 **dptr = (u8 **)ptrs; | ||
| 103 | u8 *p, *q; | ||
| 104 | int d, z, z0; | ||
