Skip to content

Commit

Permalink
Linux 5.0 compat: Disable vector instructions on 5.0+ kernels
Browse files Browse the repository at this point in the history
The 5.0 kernel no longer exports the functions we need to do vector
(SSE/SSE2/SSE3/AVX...) instructions.  Disable vector-based checksum
algorithms when building against those kernels.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes #8259
  • Loading branch information
tonyhutter authored and behlendorf committed Jan 28, 2019
1 parent ed158b1 commit 0c59329
Show file tree
Hide file tree
Showing 2 changed files with 144 additions and 39 deletions.
41 changes: 32 additions & 9 deletions config/kernel-fpu.m4
Original file line number Diff line number Diff line change
@@ -1,18 +1,41 @@
dnl #
dnl # Handle differences in kernel FPU code.
dnl #
dnl # 4.2 API change
dnl # asm/i387.h is replaced by asm/fpu/api.h
dnl # Kernel
dnl # 5.0: All kernel fpu functions are GPL only, so we can't use them.
dnl # (nothing defined)
dnl #
dnl # 4.2: Use __kernel_fpu_{begin,end}()
dnl # HAVE_UNDERSCORE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
dnl #
dnl # Pre-4.2: Use kernel_fpu_{begin,end}()
dnl # HAVE_KERNEL_FPU & KERNEL_EXPORTS_X86_FPU
dnl #
AC_DEFUN([ZFS_AC_KERNEL_FPU], [
AC_MSG_CHECKING([whether asm/fpu/api.h exists])
AC_MSG_CHECKING([which kernel_fpu function to use])
ZFS_LINUX_TRY_COMPILE([
#include <linux/kernel.h>
#include <asm/fpu/api.h>
#include <asm/i387.h>
#include <asm/xcr.h>
],[
__kernel_fpu_begin();
kernel_fpu_begin();
kernel_fpu_end();
],[
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_FPU_API_H, 1, [kernel has <asm/fpu/api.h> interface])
AC_MSG_RESULT(kernel_fpu_*)
AC_DEFINE(HAVE_KERNEL_FPU, 1, [kernel has kernel_fpu_* functions])
AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1, [kernel exports FPU functions])
],[
AC_MSG_RESULT(no)
ZFS_LINUX_TRY_COMPILE([
#include <linux/kernel.h>
#include <asm/fpu/api.h>
],[
__kernel_fpu_begin();
__kernel_fpu_end();
],[
AC_MSG_RESULT(__kernel_fpu_*)
AC_DEFINE(HAVE_UNDERSCORE_KERNEL_FPU, 1, [kernel has __kernel_fpu_* functions])
AC_DEFINE(KERNEL_EXPORTS_X86_FPU, 1, [kernel exports FPU functions])
],[
AC_MSG_RESULT(not exported)
])
])
])
Loading

4 comments on commit 0c59329

@prometheanfire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Has there been any performance evaluation for this change (just curious as to what to expect). I also wonder if compiling built-in will still have access.

@behlendorf
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on previous testing we've done if your system isn't cpu-bound you probably won't see much of a performance impact, what you will see is increased cpu-usage. I'd expect low end systems to be the most impacted.

Now that all the build issues are resolved, we can focus on re-enabling this functionality. As mentioned previously we are exploring several options. As the code currently exists, you'd probably just need to tweak the configure check it a bit to enable this when compiling built in.

@prometheanfire
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, that's good at least, the patches relating to adding vector instructions seemed to show much better scrub speeds with them.

@RJVB
Copy link

@RJVB RJVB commented on 0c59329 Apr 13, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of equal curiosity: suppose you figure out how to built (locally!) a series 5 kernel so that it exports these symbols again - it looks like you won't have to do anything extra to re-enable the use of vector instructions in ZFS?

Please sign in to comment.