summaryrefslogtreecommitdiffstats
path: root/module/zcommon
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2019-10-24 10:17:33 -0700
committerGitHub <[email protected]>2019-10-24 10:17:33 -0700
commit10fa254539ec41c6b043785d4e7ab34bce383b9f (patch)
treec26798d9a42546096cb5bf2b0afeb4ef5257d48e /module/zcommon
parentb834b58ae61063f526ce82df348440e31c58c232 (diff)
Linux 4.14, 4.19, 5.0+ compat: SIMD save/restore
Contrary to initial testing we cannot rely on these kernels to invalidate the per-cpu FPU state and restore the FPU registers. Nor can we guarantee that the kernel won't modify the FPU state which we saved in the task struck. Therefore, the kfpu_begin() and kfpu_end() functions have been updated to save and restore the FPU state using our own dedicated per-cpu FPU state variables. This has the additional advantage of allowing us to use the FPU again in user threads. So we remove the code which was added to use task queues to ensure some functions ran in kernel threads. Reviewed-by: Fabian Grünbichler <[email protected]> Reviewed-by: Tony Hutter <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Issue #9346 Closes #9403
Diffstat (limited to 'module/zcommon')
-rw-r--r--module/zcommon/zfs_fletcher.c20
-rw-r--r--module/zcommon/zfs_prop.c14
2 files changed, 18 insertions, 16 deletions
diff --git a/module/zcommon/zfs_fletcher.c b/module/zcommon/zfs_fletcher.c
index 3b4052c8a..1280ace31 100644
--- a/module/zcommon/zfs_fletcher.c
+++ b/module/zcommon/zfs_fletcher.c
@@ -726,7 +726,7 @@ fletcher_4_benchmark_impl(boolean_t native, char *data, uint64_t data_size)
* Initialize and benchmark all supported implementations.
*/
static void
-fletcher_4_benchmark(void *arg)
+fletcher_4_benchmark(void)
{
fletcher_4_ops_t *curr_impl;
int i, c;
@@ -769,20 +769,10 @@ fletcher_4_benchmark(void *arg)
void
fletcher_4_init(void)
{
-#if defined(_KERNEL)
- /*
- * For 5.0 and latter Linux kernels the fletcher 4 benchmarks are
- * run in a kernel threads. This is needed to take advantage of the
- * SIMD functionality, see linux/simd_x86.h for details.
- */
- taskqid_t id = taskq_dispatch(system_taskq, fletcher_4_benchmark,
- NULL, TQ_SLEEP);
- if (id != TASKQID_INVALID) {
- taskq_wait_id(system_taskq, id);
- } else {
- fletcher_4_benchmark(NULL);
- }
+ /* Determine the fastest available implementation. */
+ fletcher_4_benchmark();
+#if defined(_KERNEL)
/* Install kstats for all implementations */
fletcher_4_kstat = kstat_create("zfs", 0, "fletcher_4_bench", "misc",
KSTAT_TYPE_RAW, 0, KSTAT_FLAG_VIRTUAL);
@@ -795,8 +785,6 @@ fletcher_4_init(void)
fletcher_4_kstat_addr);
kstat_install(fletcher_4_kstat);
}
-#else
- fletcher_4_benchmark(NULL);
#endif
/* Finish initialization */
diff --git a/module/zcommon/zfs_prop.c b/module/zcommon/zfs_prop.c
index c42f046da..10b521065 100644
--- a/module/zcommon/zfs_prop.c
+++ b/module/zcommon/zfs_prop.c
@@ -865,10 +865,23 @@ zfs_prop_align_right(zfs_prop_t prop)
#endif
#if defined(_KERNEL)
+
+#include <sys/simd.h>
+
+#if defined(HAVE_KERNEL_FPU_INTERNAL)
+union fpregs_state **zfs_kfpu_fpregs;
+EXPORT_SYMBOL(zfs_kfpu_fpregs);
+#endif /* HAVE_KERNEL_FPU_INTERNAL */
+
static int __init
zcommon_init(void)
{
+ int error = kfpu_init();
+ if (error)
+ return (error);
+
fletcher_4_init();
+
return (0);
}
@@ -876,6 +889,7 @@ static void __exit
zcommon_fini(void)
{
fletcher_4_fini();
+ kfpu_fini();
}
module_init(zcommon_init);