@@ -3,6 +3,7 @@
#define _ASM_X86_SIMD_H
#include <asm/fpu/api.h>
+#include <linux/sched.h>
/*
* may_use_simd - whether it is allowable at this time to issue SIMD
@@ -13,4 +14,22 @@ static __must_check inline bool may_use_simd(void)
return irq_fpu_usable();
}
+/**
+ * kernel_fpu_relax - pause FPU preemption if scheduler wants
+ *
+ * Call this periodically during long loops between kernel_fpu_begin()
+ * and kernel_fpu_end() calls to avoid hogging the CPU if the
+ * scheduler wants to use the CPU for another thread
+ *
+ * Return: none
+ */
+static inline void kernel_fpu_yield(void)
+{
+ if (need_resched()) {
+ kernel_fpu_end();
+ cond_resched();
+ kernel_fpu_begin();
+ }
+}
+
#endif /* _ASM_X86_SIMD_H */
Add a function that may be called to avoid hogging the CPU between kernel_fpu_begin() and kernel_fpu_end() calls. Signed-off-by: Robert Elliott <elliott@hpe.com> --- arch/x86/include/asm/simd.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)