Skip to content

Commit

Permalink
kernel comp: fix CPU feature check for new kernels
Browse files Browse the repository at this point in the history
  • Loading branch information
ironMann committed Feb 11, 2016
1 parent 49745c1 commit 2bbdf07
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
19 changes: 14 additions & 5 deletions module/zfs/vdev_raidz_math.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,15 @@ raidz_math_impl_t vdev_raidz_scalar_impl = {
static int
raidz_math_will_sse_work(void)
{
#if defined(_KERNEL)
return (cpu_has_xmm2 && cpu_has_ssse3 && cpu_has_xmm4_1);
#if defined(__x86_64__) && defined(_KERNEL)
return (
boot_cpu_has(X86_FEATURE_MMX) &&
boot_cpu_has(X86_FEATURE_FXSR) &&
boot_cpu_has(X86_FEATURE_XMM) &&
boot_cpu_has(X86_FEATURE_XMM2) &&
boot_cpu_has(X86_FEATURE_SSSE3) &&
boot_cpu_has(X86_FEATURE_XMM4_1)
);
#elif defined(_RAIDZ_TEST)
return (!system("grep sse4_1 /proc/cpuinfo 2>&1 > /dev/null"));
#else
Expand All @@ -360,9 +367,11 @@ raidz_math_will_sse_work(void)
static int
raidz_math_will_avx2_work(void)
{
#if defined(_KERNEL) && defined(CONFIG_AS_AVX2)
return (boot_cpu_has(X86_FEATURE_AVX2) &&
boot_cpu_has(X86_FEATURE_AVX));
#if defined(__x86_64__) && defined(_KERNEL) && defined(CONFIG_AS_AVX2)
return (
boot_cpu_has(X86_FEATURE_AVX) &&
boot_cpu_has(X86_FEATURE_AVX2)
);
#elif defined(_RAIDZ_TEST)
return (!system("grep avx2 /proc/cpuinfo 2>&1 > /dev/null"));
#else
Expand Down
26 changes: 12 additions & 14 deletions module/zfs/vdev_raidz_math_sse.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,6 @@

#define __asm __asm__ __volatile__

#define ELEM_SIZE 16

#define PREFETCH_STRIDE (4)

typedef struct elem {
unsigned char b[ELEM_SIZE];
} elem_t __attribute__((aligned(ELEM_SIZE)));

/* Convert from GF log to perform multiplications using SIMD */
inline static int
fix_mul_exponent(int e) {
return ((int)vdev_raidz_pow2[e]);
}

#define _REG_CNT(_0,_1,_2,_3,_4,_5,_6,_7, N, ...) N
#define REG_CNT(r...) _REG_CNT(r, 8,7,6,5,4,3,2,1)

Expand All @@ -67,6 +53,18 @@ fix_mul_exponent(int e) {
#define R_23_(_0,_1, REG2, REG3, ...) REG2, REG3
#define R_23(REG...) R_23_(REG, 1,2)

#define ELEM_SIZE 16

typedef struct elem {
unsigned char b[ELEM_SIZE];
} elem_t __attribute__((aligned(ELEM_SIZE)));

/* Convert from GF log to perform multiplications using SIMD */
inline static int
fix_mul_exponent(int e) {
return ((int)vdev_raidz_pow2[e]);
}

#define PREFETCHNTA(ptr, offset, stride) \
{ \
switch(stride){\
Expand Down

0 comments on commit 2bbdf07

Please sign in to comment.