Skip to content

Commit 8f3f06d

Browse files
xen0nchenhuacai
authored andcommitted
raid6: Add LoongArch SIMD syndrome calculation
The algorithms work on 64 bytes at a time, which is the L1 cache line size of all current and future LoongArch cores (that we care about), as confirmed by Huacai. The code is based on the generic int.uc algorithm, unrolled 4 times for LSX and 2 times for LASX. Further unrolling does not meaningfully improve the performance according to experiments. Performance numbers measured during system boot on a 3A5000 @ 2.5GHz: > raid6: lasx gen() 12726 MB/s > raid6: lsx gen() 10001 MB/s > raid6: int64x8 gen() 2876 MB/s > raid6: int64x4 gen() 3867 MB/s > raid6: int64x2 gen() 2531 MB/s > raid6: int64x1 gen() 1945 MB/s Comparison of xor() speeds (from different boots but meaningful anyway): > lasx: 11226 MB/s > lsx: 6395 MB/s > int64x4: 2147 MB/s Performance as measured by raid6test: > raid6: lasx gen() 25109 MB/s > raid6: lsx gen() 13233 MB/s > raid6: int64x8 gen() 4164 MB/s > raid6: int64x4 gen() 6005 MB/s > raid6: int64x2 gen() 5781 MB/s > raid6: int64x1 gen() 4119 MB/s > raid6: using algorithm lasx gen() 25109 MB/s > raid6: .... xor() 14439 MB/s, rmw enabled Acked-by: Song Liu <[email protected]> Signed-off-by: WANG Xuerui <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 75ded18 commit 8f3f06d

File tree

6 files changed

+483
-0
lines changed

6 files changed

+483
-0
lines changed

include/linux/raid/pq.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ extern const struct raid6_calls raid6_vpermxor1;
108108
extern const struct raid6_calls raid6_vpermxor2;
109109
extern const struct raid6_calls raid6_vpermxor4;
110110
extern const struct raid6_calls raid6_vpermxor8;
111+
extern const struct raid6_calls raid6_lsx;
112+
extern const struct raid6_calls raid6_lasx;
111113

112114
struct raid6_recov_calls {
113115
void (*data2)(int, size_t, int, int, void **);

lib/raid6/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ raid6_pq-$(CONFIG_ALTIVEC) += altivec1.o altivec2.o altivec4.o altivec8.o \
99
vpermxor1.o vpermxor2.o vpermxor4.o vpermxor8.o
1010
raid6_pq-$(CONFIG_KERNEL_MODE_NEON) += neon.o neon1.o neon2.o neon4.o neon8.o recov_neon.o recov_neon_inner.o
1111
raid6_pq-$(CONFIG_S390) += s390vx8.o recov_s390xc.o
12+
raid6_pq-$(CONFIG_LOONGARCH) += loongarch_simd.o
1213

1314
hostprogs += mktables
1415

lib/raid6/algos.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,14 @@ const struct raid6_calls * const raid6_algos[] = {
7373
&raid6_neonx2,
7474
&raid6_neonx1,
7575
#endif
76+
#ifdef CONFIG_LOONGARCH
77+
#ifdef CONFIG_CPU_HAS_LASX
78+
&raid6_lasx,
79+
#endif
80+
#ifdef CONFIG_CPU_HAS_LSX
81+
&raid6_lsx,
82+
#endif
83+
#endif
7684
#if defined(__ia64__)
7785
&raid6_intx32,
7886
&raid6_intx16,

lib/raid6/loongarch.h

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/* SPDX-License-Identifier: GPL-2.0-or-later */
2+
/*
3+
* Copyright (C) 2023 WANG Xuerui <[email protected]>
4+
*
5+
* raid6/loongarch.h
6+
*
7+
* Definitions common to LoongArch RAID-6 code only
8+
*/
9+
10+
#ifndef _LIB_RAID6_LOONGARCH_H
11+
#define _LIB_RAID6_LOONGARCH_H
12+
13+
#ifdef __KERNEL__
14+
15+
#include <asm/cpu-features.h>
16+
#include <asm/fpu.h>
17+
18+
#else /* for user-space testing */
19+
20+
#include <sys/auxv.h>
21+
22+
/* have to supply these defines for glibc 2.37- and musl */
23+
#ifndef HWCAP_LOONGARCH_LSX
24+
#define HWCAP_LOONGARCH_LSX (1 << 4)
25+
#endif
26+
#ifndef HWCAP_LOONGARCH_LASX
27+
#define HWCAP_LOONGARCH_LASX (1 << 5)
28+
#endif
29+
30+
#define kernel_fpu_begin()
31+
#define kernel_fpu_end()
32+
33+
#define cpu_has_lsx (getauxval(AT_HWCAP) & HWCAP_LOONGARCH_LSX)
34+
#define cpu_has_lasx (getauxval(AT_HWCAP) & HWCAP_LOONGARCH_LASX)
35+
36+
#endif /* __KERNEL__ */
37+
38+
#endif /* _LIB_RAID6_LOONGARCH_H */

0 commit comments

Comments
 (0)