mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-22 10:37:35 +03:00
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 <f.gruenbichler@proxmox.com> Reviewed-by: Tony Hutter <hutter2@llnl.gov> Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov> Issue #9346 Closes #9403
This commit is contained in:
@@ -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 */
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user