I would like to know how to use the functions, kernel_fpu_begin and kernel_fpu_end, correctly. I did try to google this, but the other forums were not clear enough for me ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
1. ## How to use kernel_fpu_begin and kernel_fpu_end correctly?

I would like to know how to use the functions, kernel_fpu_begin and kernel_fpu_end, correctly.

I did try to google this, but the other forums were not clear enough for me to understand.

I did try this doing these functions, but I got couple of errors. I think it may have to do with the include header file.
May be it is the wrong one.

The code below is something I tried.
Any help is really appreciated thanks.

Code:
```#include <asm/i387.h>

static void tcp_vegas_cong_avoid(struct sock *sk, u32 ack, u32 in_flight)
{
kernel_fpu_begin();

struct tcp_sock *tp = tcp_sk(sk);
struct vegas *vegas = inet_csk_ca(sk);
int target_queue_size;
double avgRTT_Mult, rtt_Mult;

target_queue_size = 100;
avgRTT_Mult = 0.99609375; //(255/256)
rtt_Mult    = 0.00390625; //(1/256)

avgRTT = (avgRTT_Mult*avgRtt) + (rtt_Mult*rtt);

kernel_fpu_end();
}```

2. It's not available at kernel runtime either with my Debian setup. Any help would be great - thanks!!!
Being a newbie, the URL is not allowed - here's more info:
------------------
From: Linus Torvalds <torvalds@linux-foundation.org>

Touching TS_USEDFPU without touching CR0.TS is confusing, so don't do
it. By moving it into the callers, we always do the TS_USEDFPU next to
the CR0.TS accesses in the source code, and it's much easier to see how
the two go hand in hand.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
arch/x86/include/asm/i387.h | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
--- a/arch/x86/include/asm/i387.h
+++ b/arch/x86/include/asm/i387.h
@@ -259,7 +259,6 @@ static inline void fpu_save_init(struct
static inline void __save_init_fpu(struct task_struct *tsk)
{
}

static inline int fpu_fxrstor_checking(struct fpu *fpu)
@@ -290,6 +289,7 @@ static inline void __unlazy_fpu(struct t
{
__save_init_fpu(tsk);
stts();
} else
tsk->fpu_counter = 0;
@@ -356,9 +356,11 @@ static inline void kernel_fpu_begin(void

WARN_ON_ONCE(!irq_fpu_usable());
preempt_disable();
- if (me->status & TS_USEDFPU)
+ if (me->status & TS_USEDFPU) {
- else
+ me->status &= ~TS_USEDFPU;
+ /* We do 'stts()' in kernel_fpu_end() */
+ } else
clts();
}

@@ -449,6 +451,7 @@ static inline void save_init_fpu(struct
preempt_disable();
__save_init_fpu(tsk);