Skip to content

Commit fe5cbc6

Browse files
Markus Stockhausenneilbrown
authored andcommitted
md/raid6 algorithms: delta syndrome functions
v3: s-o-b comment, explanation of performance and descision for the start/stop implementation Implementing rmw functionality for RAID6 requires optimized syndrome calculation. Up to now we can only generate a complete syndrome. The target P/Q pages are always overwritten. With this patch we provide a framework for inplace P/Q modification. In the first place simply fill those functions with NULL values. xor_syndrome() has two additional parameters: start & stop. These will indicate the first and last page that are changing during a rmw run. That makes it possible to avoid several unneccessary loops and speed up calculation. The caller needs to implement the following logic to make the functions work. 1) xor_syndrome(disks, start, stop, ...): "Remove" all data of source blocks inside P/Q between (and including) start and end. 2) modify any block with start <= block <= stop 3) xor_syndrome(disks, start, stop, ...): "Reinsert" all data of source blocks into P/Q between (and including) start and end. Pages between start and stop that won't be changed should be filled with a pointer to the kernel zero page. The reasons for not taking NULL pages are: 1) Algorithms cross the whole source data line by line. Thus avoid additional branches. 2) Having a NULL page avoids calculating the XOR P parity but still need calulation steps for the Q parity. Depending on the algorithm unrolling that might be only a difference of 2 instructions per loop. The benchmark numbers of the gen_syndrome() functions are displayed in the kernel log. Do the same for the xor_syndrome() functions. This will help to analyze performance problems and give an rough estimate how well the algorithm works. The choice of the fastest algorithm will still depend on the gen_syndrome() performance. With the start/stop page implementation the speed can vary a lot in real life. E.g. a change of page 0 & page 15 on a stripe will be harder to compute than the case where page 0 & page 1 are XOR candidates. To be not to enthusiatic about the expected speeds we will run a worse case test that simulates a change on the upper half of the stripe. So we do: 1) calculation of P/Q for the upper pages 2) continuation of Q for the lower (empty) pages Signed-off-by: Markus Stockhausen <stockhausen@collogia.de> Signed-off-by: NeilBrown <neilb@suse.de>
1 parent dabc4ec commit fe5cbc6

10 files changed

Lines changed: 50 additions & 8 deletions

File tree

include/linux/raid/pq.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ extern const char raid6_empty_zero_page[PAGE_SIZE];
7272
/* Routine choices */
7373
struct raid6_calls {
7474
void (*gen_syndrome)(int, size_t, void **);
75+
void (*xor_syndrome)(int, int, int, size_t, void **);
7576
int (*valid)(void); /* Returns 1 if this routine set is usable */
7677
const char *name; /* Name of this routine set */
7778
int prefer; /* Has special performance attribute */

lib/raid6/algos.c

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -131,11 +131,12 @@ static inline const struct raid6_recov_calls *raid6_choose_recov(void)
131131
static inline const struct raid6_calls *raid6_choose_gen(
132132
void *(*const dptrs)[(65536/PAGE_SIZE)+2], const int disks)
133133
{
134-
unsigned long perf, bestperf, j0, j1;
134+
unsigned long perf, bestgenperf, bestxorperf, j0, j1;
135+
int start = (disks>>1)-1, stop = disks-3; /* work on the second half of the disks */
135136
const struct raid6_calls *const *algo;
136137
const struct raid6_calls *best;
137138

138-
for (bestperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) {
139+
for (bestgenperf = 0, bestxorperf = 0, best = NULL, algo = raid6_algos; *algo; algo++) {
139140
if (!best || (*algo)->prefer >= best->prefer) {
140141
if ((*algo)->valid && !(*algo)->valid())
141142
continue;
@@ -153,19 +154,45 @@ static inline const struct raid6_calls *raid6_choose_gen(
153154
}
154155
preempt_enable();
155156

156-
if (perf > bestperf) {
157-
bestperf = perf;
157+
if (perf > bestgenperf) {
158+
bestgenperf = perf;
158159
best = *algo;
159160
}
160-
pr_info("raid6: %-8s %5ld MB/s\n", (*algo)->name,
161+
pr_info("raid6: %-8s gen() %5ld MB/s\n", (*algo)->name,
161162
(perf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2));
163+
164+
if (!(*algo)->xor_syndrome)
165+
continue;
166+
167+
perf = 0;
168+
169+
preempt_disable();
170+
j0 = jiffies;
171+
while ((j1 = jiffies) == j0)
172+
cpu_relax();
173+
while (time_before(jiffies,
174+
j1 + (1<<RAID6_TIME_JIFFIES_LG2))) {
175+
(*algo)->xor_syndrome(disks, start, stop,
176+
PAGE_SIZE, *dptrs);
177+
perf++;
178+
}
179+
preempt_enable();
180+
181+
if (best == *algo)
182+
bestxorperf = perf;
183+
184+
pr_info("raid6: %-8s xor() %5ld MB/s\n", (*algo)->name,
185+
(perf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2+1));
162186
}
163187
}
164188

165189
if (best) {
166-
pr_info("raid6: using algorithm %s (%ld MB/s)\n",
190+
pr_info("raid6: using algorithm %s gen() %ld MB/s\n",
167191
best->name,
168-
(bestperf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2));
192+
(bestgenperf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2));
193+
if (best->xor_syndrome)
194+
pr_info("raid6: .... xor() %ld MB/s, rmw enabled\n",
195+
(bestxorperf*HZ) >> (20-16+RAID6_TIME_JIFFIES_LG2+1));
169196
raid6_call = *best;
170197
} else
171198
pr_err("raid6: Yikes! No algorithm found!\n");

lib/raid6/altivec.uc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ int raid6_have_altivec(void)
119119

120120
const struct raid6_calls raid6_altivec$# = {
121121
raid6_altivec$#_gen_syndrome,
122+
NULL, /* XOR not yet implemented */
122123
raid6_have_altivec,
123124
"altivecx$#",
124125
0

lib/raid6/avx2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ static void raid6_avx21_gen_syndrome(int disks, size_t bytes, void **ptrs)
8989

9090
const struct raid6_calls raid6_avx2x1 = {
9191
raid6_avx21_gen_syndrome,
92+
NULL, /* XOR not yet implemented */
9293
raid6_have_avx2,
9394
"avx2x1",
9495
1 /* Has cache hints */
@@ -150,6 +151,7 @@ static void raid6_avx22_gen_syndrome(int disks, size_t bytes, void **ptrs)
150151

151152
const struct raid6_calls raid6_avx2x2 = {
152153
raid6_avx22_gen_syndrome,
154+
NULL, /* XOR not yet implemented */
153155
raid6_have_avx2,
154156
"avx2x2",
155157
1 /* Has cache hints */
@@ -242,6 +244,7 @@ static void raid6_avx24_gen_syndrome(int disks, size_t bytes, void **ptrs)
242244

243245
const struct raid6_calls raid6_avx2x4 = {
244246
raid6_avx24_gen_syndrome,
247+
NULL, /* XOR not yet implemented */
245248
raid6_have_avx2,
246249
"avx2x4",
247250
1 /* Has cache hints */

lib/raid6/int.uc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ static void raid6_int$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
109109

110110
const struct raid6_calls raid6_intx$# = {
111111
raid6_int$#_gen_syndrome,
112-
NULL, /* always valid */
112+
NULL, /* XOR not yet implemented */
113+
NULL, /* always valid */
113114
"int" NSTRING "x$#",
114115
0
115116
};

lib/raid6/mmx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ static void raid6_mmx1_gen_syndrome(int disks, size_t bytes, void **ptrs)
7676

7777
const struct raid6_calls raid6_mmxx1 = {
7878
raid6_mmx1_gen_syndrome,
79+
NULL, /* XOR not yet implemented */
7980
raid6_have_mmx,
8081
"mmxx1",
8182
0
@@ -134,6 +135,7 @@ static void raid6_mmx2_gen_syndrome(int disks, size_t bytes, void **ptrs)
134135

135136
const struct raid6_calls raid6_mmxx2 = {
136137
raid6_mmx2_gen_syndrome,
138+
NULL, /* XOR not yet implemented */
137139
raid6_have_mmx,
138140
"mmxx2",
139141
0

lib/raid6/neon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
} \
4343
struct raid6_calls const raid6_neonx ## _n = { \
4444
raid6_neon ## _n ## _gen_syndrome, \
45+
NULL, /* XOR not yet implemented */ \
4546
raid6_have_neon, \
4647
"neonx" #_n, \
4748
0 \

lib/raid6/sse1.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ static void raid6_sse11_gen_syndrome(int disks, size_t bytes, void **ptrs)
9292

9393
const struct raid6_calls raid6_sse1x1 = {
9494
raid6_sse11_gen_syndrome,
95+
NULL, /* XOR not yet implemented */
9596
raid6_have_sse1_or_mmxext,
9697
"sse1x1",
9798
1 /* Has cache hints */
@@ -154,6 +155,7 @@ static void raid6_sse12_gen_syndrome(int disks, size_t bytes, void **ptrs)
154155

155156
const struct raid6_calls raid6_sse1x2 = {
156157
raid6_sse12_gen_syndrome,
158+
NULL, /* XOR not yet implemented */
157159
raid6_have_sse1_or_mmxext,
158160
"sse1x2",
159161
1 /* Has cache hints */

lib/raid6/sse2.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static void raid6_sse21_gen_syndrome(int disks, size_t bytes, void **ptrs)
9090

9191
const struct raid6_calls raid6_sse2x1 = {
9292
raid6_sse21_gen_syndrome,
93+
NULL, /* XOR not yet implemented */
9394
raid6_have_sse2,
9495
"sse2x1",
9596
1 /* Has cache hints */
@@ -152,6 +153,7 @@ static void raid6_sse22_gen_syndrome(int disks, size_t bytes, void **ptrs)
152153

153154
const struct raid6_calls raid6_sse2x2 = {
154155
raid6_sse22_gen_syndrome,
156+
NULL, /* XOR not yet implemented */
155157
raid6_have_sse2,
156158
"sse2x2",
157159
1 /* Has cache hints */
@@ -250,6 +252,7 @@ static void raid6_sse24_gen_syndrome(int disks, size_t bytes, void **ptrs)
250252

251253
const struct raid6_calls raid6_sse2x4 = {
252254
raid6_sse24_gen_syndrome,
255+
NULL, /* XOR not yet implemented */
253256
raid6_have_sse2,
254257
"sse2x4",
255258
1 /* Has cache hints */

lib/raid6/tilegx.uc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ void raid6_tilegx$#_gen_syndrome(int disks, size_t bytes, void **ptrs)
8080

8181
const struct raid6_calls raid6_tilegx$# = {
8282
raid6_tilegx$#_gen_syndrome,
83+
NULL, /* XOR not yet implemented */
8384
NULL,
8485
"tilegx$#",
8586
0

0 commit comments

Comments
 (0)