Skip to content

Commit

Permalink
FreeBSD: Don't save user FPU context in kernel threads
Browse files Browse the repository at this point in the history
Reviewed-by: Alexander Motin <[email protected]>
Reviewed-by: Ryan Moeller <[email protected]>
Signed-off-by: Matt Macy <[email protected]>
Closes openzfs#10899
  • Loading branch information
mattmacy authored Sep 23, 2020
1 parent eb267f0 commit 3dad29f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 8 additions & 8 deletions include/os/freebsd/spl/sys/simd_x86.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <sys/cdefs.h>
#include <sys/types.h>
#include <sys/systm.h>
#include <sys/proc.h>
#ifdef __i386__
#include <x86/fpu.h>
#else
Expand All @@ -42,16 +43,15 @@
#define kfpu_allowed() 1
#define kfpu_initialize(tsk) do {} while (0)

#define kfpu_begin() { \
critical_enter(); \
fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX); \
#define kfpu_begin() { \
if (__predict_false(!is_fpu_kern_thread(0))) \
fpu_kern_enter(curthread, NULL, FPU_KERN_NOCTX);\
}

#define kfpu_end() \
{ \
fpu_kern_leave(curthread, NULL); \
critical_exit(); \
}
#define kfpu_end() { \
if (__predict_false(curpcb->pcb_flags & PCB_FPUNOSAVE)) \
fpu_kern_leave(curthread, NULL); \
}

/*
* Check if OS supports AVX and AVX2 by checking XCR0
Expand Down
4 changes: 4 additions & 0 deletions module/os/freebsd/spl/spl_taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,10 @@ taskq_tsd_set(void *context)
{
taskq_t *tq = context;

#if defined(__amd64__) || defined(__i386__) || defined(__aarch64__)
if (context != NULL && tsd_get(taskq_tsd) == NULL)
fpu_kern_thread(FPU_KERN_NORMAL);
#endif
tsd_set(taskq_tsd, tq);
}

Expand Down

0 comments on commit 3dad29f

Please sign in to comment.