Skip to contentSkip to conversation

fpu context switch issue

Xenomai-help Steven Seeger 3 participants 33 messages Nov 3, 2008 – Nov 26, 2008 x86

lore
Share & tools
lore
#0 lore raw

I'm having a weird issue. Sometimes when I run the attached program I see one of the "shouldn't see this" printouts. However, it only fails if I also link in another userspace library that doesn't do anything. (No libraries are being called here.)

I've had issues with a couple of other xenomai apps. I get a nan on a double operation sometimes right after the app first loads, and then it's ok after that. This error in the attached program always happens on the first call in the higher priority task (started second.)

Running 2.4.5 with 2.6.26.3 and also 2.6.25.9. AMD Geode LX800 board.

Any suggestions?

Thanks,

Steven

#1 lore raw
Quoted 4 lines · Steven Seeger

I'm having a weird issue. Sometimes when I run the attached program I see one of the "shouldn't see this" printouts. However, it only fails if I also link in another userspace library that doesn't do anything. (No libraries are being called here.)

Some libraries do things when loaded, even if no function is called: if a C++ library declares a global or static object with a non trivial constructor, the constructor is run when the library is loaded. The same goes for C functions declared with the "constructor" attribute.

Quoted 11 lines

I've had issues with a couple of other xenomai apps. I get a nan on a double operation sometimes right after the app first loads, and then it's ok after that. This error in the attached program always happens on the first call in the higher priority task (started second.)

Running 2.4.5 with 2.6.26.3 and also 2.6.25.9. AMD Geode LX800 board.

Could you try to run the "switchtest" program, and see if it has bugs too ? Also, do you see the "fxsr" flag in /proc/cpuinfo ?

Signature · 1 line
                                                 Gilles.
#2 lore raw

Hi Gilles. Thank you for getting back to me.

I do not see "fxsr" in /proc/cpuinfo. I checked around with Google and it seems this chip doesn't have FXSR support. Do I need to do something else in this case? We are currently using a new board. I will check /proc/cpuinfo on the old board and see if it says FXSR. We never had this problem with the old board.

I understand that some libraries do things on startup, but this one doesn't seem to. In fact, linking that library in only adds 8 bytes to the code. Very strange. I really think it would fail even without linking that in but I can't produce it. I have other apps that are more complicated but do not use that library that also have issues with doubles on startup.

I also realized I didn't remove access to the run variable when I attached the code. That variable is obviously not being used.

I will post the results of switchtest later today. Thank you for the suggestion.

Steven

Quoted 9 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Monday, November 03, 2008 3:10 AM
To: Steven Seeger
Cc: [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 1 line · Steven Seeger

I'm having a weird issue. Sometimes when I run the attached program

I

Quoted 1 line
Quoted 1 line

see one of the "shouldn't see this" printouts. However, it only

fails

Quoted 6 lines

if

Quoted 1 line

I also link in another userspace library that doesn't do anything.

(No

Quoted 1 line

libraries are being called here.)

Some libraries do things when loaded, even if no function is called:

if

Quoted 9 lines

a C++ library declares a global or static object with a non trivial constructor, the constructor is run when the library is loaded. The same
goes for C functions declared with the "constructor" attribute.

Quoted 4 lines

I've had issues with a couple of other xenomai apps. I get a nan on

a

Quoted 2 lines
Quoted 2 lines

double operation sometimes right after the app first loads, and then it's ok after that. This error in the attached program always

happens

Quoted 6 lines

on

Quoted 5 lines

the first call in the higher priority task (started second.)

Running 2.4.5 with 2.6.26.3 and also 2.6.25.9. AMD Geode LX800

board.

Quoted 6 lines

Could you try to run the "switchtest" program, and see if it has bugs too ? Also, do you see the "fxsr" flag in /proc/cpuinfo ?

--
Gilles.

#3 lore raw
Quoted 7 lines · Steven Seeger

Hi Gilles. Thank you for getting back to me.

I do not see "fxsr" in /proc/cpuinfo. I checked around with Google and it seems this chip doesn't have FXSR support. Do I need to do something else in this case? We are currently using a new board. I will check /proc/cpuinfo on the old board and see if it says FXSR. We never had this problem with the old board.

No, the fact that you have no support for FXSR is not a problem, it was just a question to try and reproduce the issue you face.

Signature · 1 line
                                                 Gilles.
#4 lore raw

Hello,

The switchtest output is as follows. This was run on 2.4.5 with 2.6.26.3 AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from my start-up script. I don't know if that is an expected requirement prior to running the test.

== Testing FPU check routines...
r0: 1 != 2
r1: 1 != 2
r2: 1 != 2
r3: 1 != 2
r4: 1 != 2
r5: 1 != 2
r6: 1 != 2
r7: 1 != 2
== FPU check routines: OK.
== Threads: sleeper_ufps-0 rtk-1 rtk-2 rtk_fp-3 rtk_fp-4 rtk_fp_ufpp-5 rtk_fp_ufpp-6 rtup-7 rtup-8 rtup_ufpp-9 rtup_ufpp-10 rtus-11 rtus-12 rtus_ufps-13 rtus_ufps-14 rtuo-15 rtuo-16 rtuo_ufpp-17 rtuo_ufpp-18 rtuo_ufps-19 rtuo_ufps-20 rtuo_ufpp_ufps-21 rtuo_ufpp_ufps-22

RTT|  00:00:01
RTH|ctx switches|-------total
RTD|       17250|       17250
RTD|       17250|       34500
RTD|       17250|       51750
RTD|       17250|       69000
RTD|       17273|       86273
RTD|       17273|      103546
RTD|       17273|      120819
RTD|       17250|      138069
RTD|       17250|      155319
RTD|       17273|      172592
RTD|       17250|      189842
RTD|       17250|      207092
RTD|       17273|      224365
RTD|       17273|      241638
RTD|       17273|      258911
RTD|       17250|      276161
RTD|       17250|      293411
RTD|       17250|      310661
RTD|       17273|      327934
RTD|       17273|      345207
RTD|       17250|      362457

Thanks in advance for any help.

Mark Saiia

Quoted 6 lines

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

#5 lore raw
Quoted 46 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with 2.6.26.3 AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from my start-up script. I don't know if that is an expected requirement prior to running the test.

== Testing FPU check routines...
r0: 1 != 2
r1: 1 != 2
r2: 1 != 2
r3: 1 != 2
r4: 1 != 2
r5: 1 != 2
r6: 1 != 2
r7: 1 != 2
== FPU check routines: OK.
== Threads: sleeper_ufps-0 rtk-1 rtk-2 rtk_fp-3 rtk_fp-4 rtk_fp_ufpp-5 rtk_fp_ufpp-6 rtup-7 rtup-8 rtup_ufpp-9 rtup_ufpp-10 rtus-11 rtus-12 rtus_ufps-13 rtus_ufps-14 rtuo-15 rtuo-16 rtuo_ufpp-17 rtuo_ufpp-18 rtuo_ufps-19 rtuo_ufps-20 rtuo_ufpp_ufps-21 rtuo_ufpp_ufps-22

RTT|  00:00:01
RTH|ctx switches|-------total
RTD|       17250|       17250
RTD|       17250|       34500
RTD|       17250|       51750
RTD|       17250|       69000
RTD|       17273|       86273
RTD|       17273|      103546
RTD|       17273|      120819
RTD|       17250|      138069
RTD|       17250|      155319
RTD|       17273|      172592
RTD|       17250|      189842
RTD|       17250|      207092
RTD|       17273|      224365
RTD|       17273|      241638
RTD|       17273|      258911
RTD|       17250|      276161
RTD|       17250|      293411
RTD|       17250|      310661
RTD|       17273|      327934
RTD|       17273|      345207
RTD|       17250|      362457
Quoted 3 lines

Thanks in advance for any help.

Mark Saiia

Hi,

It seems you do not get the same error with switchtest as you get with your test program. I had a look at linux fpu handling, and it seems to be very different from Xenomai fpu handling. I need to dig a little bit more, but will send you a patch soon.

Regards.

Signature · 1 line
					    Gilles.
#6 lore raw
Quoted 52 lines · Gilles Chanteperdrix
Quoted 46 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with 2.6.26.3 AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from my start-up script. I don't know if that is an expected requirement prior to running the test.

== Testing FPU check routines...
r0: 1 != 2
r1: 1 != 2
r2: 1 != 2
r3: 1 != 2
r4: 1 != 2
r5: 1 != 2
r6: 1 != 2
r7: 1 != 2
== FPU check routines: OK.
== Threads: sleeper_ufps-0 rtk-1 rtk-2 rtk_fp-3 rtk_fp-4 rtk_fp_ufpp-5 rtk_fp_ufpp-6 rtup-7 rtup-8 rtup_ufpp-9 rtup_ufpp-10 rtus-11 rtus-12 rtus_ufps-13 rtus_ufps-14 rtuo-15 rtuo-16 rtuo_ufpp-17 rtuo_ufpp-18 rtuo_ufps-19 rtuo_ufps-20 rtuo_ufpp_ufps-21 rtuo_ufpp_ufps-22

RTT|  00:00:01
RTH|ctx switches|-------total
RTD|       17250|       17250
RTD|       17250|       34500
RTD|       17250|       51750
RTD|       17250|       69000
RTD|       17273|       86273
RTD|       17273|      103546
RTD|       17273|      120819
RTD|       17250|      138069
RTD|       17250|      155319
RTD|       17273|      172592
RTD|       17250|      189842
RTD|       17250|      207092
RTD|       17273|      224365
RTD|       17273|      241638
RTD|       17273|      258911
RTD|       17250|      276161
RTD|       17250|      293411
RTD|       17250|      310661
RTD|       17273|      327934
RTD|       17273|      345207
RTD|       17250|      362457
Quoted 3 lines

Thanks in advance for any help.

Mark Saiia

Quoted 6 lines

Hi,

It seems you do not get the same error with switchtest as you get with your test program. I had a look at linux fpu handling, and it seems to be very different from Xenomai fpu handling. I need to dig a little bit more, but will send you a patch soon.

Here comes the promised patch.

asm-x86/bits/pod_32.h +26 -5
Index: include/asm-x86/bits/pod_32.h
===================================================================
@@ -194,16 +194,37 @@ static inline void xnarch_init_thread(xn
 static inline void xnarch_init_fpu(xnarchtcb_t * tcb)
 {
 	struct task_struct *task = tcb->user_task;
+	x86_fpu_state *fpup = tcb->fpup;
 	/* Initialize the FPU for a task. This must be run on behalf of the
 	   task. */
 
-	__asm__ __volatile__("clts; fninit");
+	if (cpu_has_fxsr) {
+		struct i837_fxsave_struct *fx = &fpup->fxsave;
 
-	if (cpu_has_xmm) {
-		unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
-		__asm__ __volatile__("ldmxcsr %0"::"m"(__mxcsr));
-	}
+		memset(fx, 0, sizeof(*fx));
+		fx->cwd = 0x37f;
+		if (cpu_has_xmm) {
+			unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
+			fx->mxcsr = __mxcsr;
+		}
+
+		clts();
+
+		__asm__ __volatile__("fxrstor %0": /* no output */ :"m"(*fx));
+	} else {
+		struct i387_fsave_struct *fp = &fpup->fsave;
+
+		memset(fp, 0, sizeof(*fp));
+		fp->cwd = 0xffff037fu;
+		fp->swd = 0xffff0000u;
+		fp->twd = 0xffffffffu;
+		fp->fos = 0xffff0000u;
+		
+		clts();
 
+		__asm__ __volatile__("frstor %0": /* no output */ :"m"(*fp));
+	}
+	
 	if (task) {
 		/* Real-time shadow FPU initialization: tell Linux that this
 		   thread initialized its FPU hardware. The fpu usage bit is
Signature · 1 line
					    Gilles.
#7 lore raw

Hello,

The patch would not apply cleanly(rejected Hunk) against 2.4.5 w/linux2.6.26.3 or svn 4368 w/linux2.6.26.7.

I edited pod_32.h to try and incorporate the changes listed in the patch.

Building with both Xenomai/Linux combinations gives the following errors. include/asm/xenomai/bits/pod_32.h: In function 'xnarch_init_fpu':
include/asm/xenomai/bits/pod_32.h:220: error: 'x86_fpu_state' undeclared (first use in this function) include/asm/xenomai/bits/pod_32.h:220: error: (Each undeclared identifier is reported only once
include/asm/xenomai/bits/pod_32.h:220: error: for each function it appears in.)
include/asm/xenomai/bits/pod_32.h:220: error: 'fpup' undeclared (first use in this function)
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:229: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:230: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:233: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:238: error: dereferencing pointer to incomplete type
include/asm/xenomai/bits/pod_32.h:238: error: memory input 0 is not directly addressable

My init_fpu function looks like this, which I believe corresponds to your patch.

       struct task_struct *task = tcb->user_task;
       x86_fpu_state *fpup = tcb->fpup;

       /* Initialize the FPU for a task. This must be run on behalf of the
       task. */

       if (cpu_has_fxsr) {
               struct i837_fxsave_struct *fx = &fpup->fxsave;

               memset(fx, 0, sizeof(*fx));
               fx->cwd = 0x37f;
               if (cpu_has_xmm) {
                       unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
                       fx->mxcsr = __mxcsr;
               }

               clts();

               __asm__ __volatile__("fxrstor %0": /* no output */
:"m"(*fx));
       } else {
               struct i387_fsave_struct *fp = &fpup->fsave;

               memset(fp, 0, sizeof(*fp));
               fp->cwd = 0xffff037fu;
               fp->swd = 0xffff0000u;
               fp->twd = 0xffffffffu;
               fp->fos = 0xffff0000u;

               clts();

               __asm__ __volatile__("frstor %0": /* no output */ :"m"(*fp));
       }
        if (task) {
        /* Real-time shadow FPU initialization: tell Linux that this
           thread initialized its FPU hardware. The fpu usage bit is
           necessary for xnarch_save_fpu to save the FPU state at next
           switch. */
        xnarch_set_fpu_init(task);
        wrap_set_fpu_used(task);
    }

Please let me know, if I did anything incorrectly, or if the patch was not completely posted.

Thanks for your work,

Mark

Quoted 119 lines · Gilles Chanteperdrix
Quoted 4 lines · Gilles Chanteperdrix
Quoted 3 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with

2.6.26.3

Quoted 3 lines
Quoted 3 lines

AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from my start-up script. I don't know if that is an expected requirement prior

to

Quoted 45 lines
Quoted 40 lines

running the test.

== Testing FPU check routines...
r0: 1 != 2
r1: 1 != 2
r2: 1 != 2
r3: 1 != 2
r4: 1 != 2
r5: 1 != 2
r6: 1 != 2
r7: 1 != 2
== FPU check routines: OK.
== Threads: sleeper_ufps-0 rtk-1 rtk-2 rtk_fp-3 rtk_fp-4 rtk_fp_ufpp-5 rtk_fp_ufpp-6 rtup-7 rtup-8 rtup_ufpp-9 rtup_ufpp-10 rtus-11 rtus-12 rtus_ufps-13 rtus_ufps-14 rtuo-15 rtuo-16 rtuo_ufpp-17 rtuo_ufpp-18 rtuo_ufps-19 rtuo_ufps-20 rtuo_ufpp_ufps-21 rtuo_ufpp_ufps-22

RTT|  00:00:01
RTH|ctx switches|-------total
RTD|       17250|       17250
RTD|       17250|       34500
RTD|       17250|       51750
RTD|       17250|       69000
RTD|       17273|       86273
RTD|       17273|      103546
RTD|       17273|      120819
RTD|       17250|      138069
RTD|       17250|      155319
RTD|       17273|      172592
RTD|       17250|      189842
RTD|       17250|      207092
RTD|       17273|      224365
RTD|       17273|      241638
RTD|       17273|      258911
RTD|       17250|      276161
RTD|       17250|      293411
RTD|       17250|      310661
RTD|       17273|      327934
RTD|       17273|      345207
RTD|       17250|      362457
Quoted 3 lines

Thanks in advance for any help.

Mark Saiia

Quoted 6 lines

Hi,

It seems you do not get the same error with switchtest as you get with your test program. I had a look at linux fpu handling, and it seems to be very different from Xenomai fpu handling. I need to dig a little bit more, but will send you a patch soon.

Here comes the promised patch.

Index: include/asm-x86/bits/pod_32.h
===================================================================

asm-x86/bits/pod_32.h (working copy) renamed from asm-x86/bits/pod_32.h (revision 4355) +26 -5
@@ -194,16 +194,37 @@ static inline void xnarch_init_thread(xn
 static inline void xnarch_init_fpu(xnarchtcb_t * tcb)
 {
       struct task_struct *task = tcb->user_task;
+       x86_fpu_state *fpup = tcb->fpup;
       /* Initialize the FPU for a task. This must be run on behalf of the
          task. */
 
-       __asm__ __volatile__("clts; fninit");
+       if (cpu_has_fxsr) {
+               struct i837_fxsave_struct *fx = &fpup->fxsave;
 
-       if (cpu_has_xmm) {
-               unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
-               __asm__ __volatile__("ldmxcsr %0"::"m"(__mxcsr));
-       }
+               memset(fx, 0, sizeof(*fx));
+               fx->cwd = 0x37f;
+               if (cpu_has_xmm) {
+                       unsigned long __mxcsr = 0x1f80UL & 0xffbfUL;
+                       fx->mxcsr = __mxcsr;
+               }
+
+               clts();
+
+               __asm__ __volatile__("fxrstor %0": /* no output */
 :"m"(*fx));
+       } else {
+               struct i387_fsave_struct *fp = &fpup->fsave;
+
+               memset(fp, 0, sizeof(*fp));
+               fp->cwd = 0xffff037fu;
+               fp->swd = 0xffff0000u;
+               fp->twd = 0xffffffffu;
+               fp->fos = 0xffff0000u;
+
+               clts();
 
+               __asm__ __volatile__("frstor %0": /* no output */
 :"m"(*fp));
+       }
+
       if (task) {

/* Real-time shadow FPU initialization: tell Linux that this
thread initialized its FPU hardware. The fpu usage bit is

--
Gilles.

#8 lore raw
Quoted 7 lines · Mark Saiia

Hello,

The patch would not apply cleanly(rejected Hunk) against 2.4.5 w/linux2.6.26.3 or svn 4368 w/linux2.6.26.7.
(...)
Please let me know, if I did anything incorrectly, or if the patch was not completely posted.

No, I probably made the patch against 2.6.27, I did not test it. Could you try the patch you made ?

Signature · 1 line
                    Gilles.
#9 lore raw

The problem was you declared x86_fpu_state instead of x86_fpustate. No big deal.

Steven

Quoted 31 lines

-----Original Message-----
From: [email protected] [mailto:xenomai-help- [email protected]] On Behalf Of Gilles Chanteperdrix
Sent: Tuesday, November 11, 2008 4:21 AM
To: Mark Saiia
Cc: [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 6 lines · Mark Saiia

Hello,

The patch would not apply cleanly(rejected Hunk) against 2.4.5 w/linux2.6.26.3 or svn 4368 w/linux2.6.26.7.
(...)
Please let me know, if I did anything incorrectly, or if the patch

was not

Quoted 1 line

completely posted.

No, I probably made the patch against 2.6.27, I did not test it. Could you
try the patch you made ?

--
Gilles.

_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

#10 lore raw

I applied the patch to Xenomai-2.4.5 with kernel 2.6.26.3 and observed the erroneous behavior. I did the same with linux-2.6.27.5 and Xenomai r4372 and noticed the same behavior. Please let me know if I can run additional tests, if you need any more information, or how to potentially fix this issue.

Thank you,

Mark

#11 lore raw
Quoted 5 lines · Mark Saiia

I applied the patch to Xenomai-2.4.5 with kernel 2.6.26.3 and observed the erroneous behavior. I did the same with linux-2.6.27.5 and Xenomai r4372 and noticed the same behavior. Please let me know if I can run additional tests, if you need any more information, or how to potentially fix this issue.

So, fninit is not the culprit. What could happen is that we do not really get an FPU fault upon first access to the FPU. To know this, we should test the state of the ts bit before the first use of FPU in each thread.

I will send a patch to do this.

Signature · 1 line
					    Gilles.
#12 lore raw
In reply to Mark Saiia
Quoted 7 lines · Mark Saiia

I applied the patch to Xenomai-2.4.5 with kernel 2.6.26.3 and observed the erroneous behavior. I did the same with linux-2.6.27.5 and Xenomai r4372 and noticed the same behavior. Please let me know if I can run additional tests, if you need any more information, or how to potentially fix this issue.

Thank you,

Could you try the following patch ?

Signature · 1 line
                                                 Gilles.
arch/x86/kernel/traps_32.c +7 -2
index f422387..f9f213a 100644
@@ -1159,6 +1159,8 @@ asmlinkage void math_state_restore(void)
 	struct task_struct *tsk = thread->task;
 	unsigned long flags;
 
+ 	local_irq_save_hw_cond(flags);
+#ifndef CONFIG_IPIPE
 	if (!tsk_used_math(tsk)) {
 		local_irq_enable();
 		/*
@@ -1173,8 +1175,11 @@ asmlinkage void math_state_restore(void)
 		}
 		local_irq_disable();
 	}
-
- 	local_irq_save_hw_cond(flags);
+#else /* CONFIG_IPIPE */
+	if (!tsk_used_math(tsk))
+		/* No alloc, can not fail. */
+		init_fpu(tsk)
+#endif /* CONFIG_IPIPE */
 	clts();				/* Allow maths ops (or we recurse) */
 	restore_fpu(tsk);
 	thread->status |= TS_USEDFPU;	/* So we fnsave on switch_to() */
#13 lore raw

Gilles,

No noticeable difference using 2.4.5 w/ 2.6.26.3. I was testing using the app we first noticed the behavior on. I will run the simple test program tomorrow, but fully expect to see the erroneous behavior. I also had the chance to test the patch on a GX1 board, and noticed the error as well. We have a version of the app, that I was testing today, running on 2.6.23.12 w/ Xenomai svn of around February 2008 (I don't have the revision number in front of me at the moment) that works properly.

Thanks,

Mark

Quoted 46 lines · Gilles Chanteperdrix
Quoted 1 line · Mark Saiia

I applied the patch to Xenomai-2.4.5 with kernel 2.6.26.3 and observed

the

Quoted 2 lines

erroneous behavior. I did the same with linux-2.6.27.5 and Xenomai r4372 and noticed the same behavior. Please let me know if I can run

additional

Quoted 4 lines

tests, if you need any more information, or how to potentially fix this issue.

Thank you,

Could you try the following patch ?

--
Gilles.

arch/x86/kernel/traps_32.c +7 -2
index f422387..f9f213a 100644
@@ -1159,6 +1159,8 @@ asmlinkage void math_state_restore(void)
       struct task_struct *tsk = thread->task;
       unsigned long flags;
 
+       local_irq_save_hw_cond(flags);
+#ifndef CONFIG_IPIPE
       if (!tsk_used_math(tsk)) {
               local_irq_enable();
               /*
@@ -1173,8 +1175,11 @@ asmlinkage void math_state_restore(void)
               }
               local_irq_disable();
       }
-
-       local_irq_save_hw_cond(flags);
+#else /* CONFIG_IPIPE */
+       if (!tsk_used_math(tsk))
+               /* No alloc, can not fail. */
+               init_fpu(tsk)
+#endif /* CONFIG_IPIPE */
       clts();                         /* Allow maths ops (or we recurse)
 */
       restore_fpu(tsk);
       thread->status |= TS_USEDFPU;   /* So we fnsave on switch_to() */
#14 lore raw
Quoted 9 lines · Mark Saiia

Gilles,

No noticeable difference using 2.4.5 w/ 2.6.26.3. I was testing using the app we first noticed the behavior on. I will run the simple test program tomorrow, but fully expect to see the erroneous behavior. I also had the chance to test the patch on a GX1 board, and noticed the error as well. We have a version of the app, that I was testing today, running on 2.6.23.12 w/ Xenomai svn of around February 2008 (I don't have the revision number in front of me at the moment) that works properly.

Could you test 2.6.23 with Xenomai 2.4.5? This way we would know if we are looking for a problem in the I-pipe patch or in Xenomai.

Signature · 1 line
					    Gilles.
#15 lore raw

Just a quick update. I haven't had a chance to do as you suggested (2.6.23 w/2.4.5), but will get to it when I have a chance. My previous post was incorrect. The older version of the app was somewhat different. We recreated the environment that was on on the app backup flash with Xenomai 2.6.23.12 w/ Xenomai r3415. The newer version of the app still exhibits floating point errors on this older platform. Yet we ran the simple test program numerous times on the older platform and did not see any incorrect behavior. I am attempting to make a determination as to what in the larger app causes the floating point issue to arise.

Mark

Quoted 20 lines · Gilles Chanteperdrix
Quoted 3 lines · Mark Saiia

Gilles,

No noticeable difference using 2.4.5 w/ 2.6.26.3. I was testing using

the

Quoted 3 lines

app we first noticed the behavior on. I will run the simple test program tomorrow, but fully expect to see the erroneous behavior. I also had the chance to test the patch on a GX1 board, and noticed the error as well.

We

Quoted 1 line

have a version of the app, that I was testing today, running on

2.6.23.12 w/

Quoted 2 lines

Xenomai svn of around February 2008 (I don't have the revision number in front of me at the moment) that works properly.

Could you test 2.6.23 with Xenomai 2.4.5? This way we would know if we are looking for a problem in the I-pipe patch or in Xenomai.

--
Gilles.

#16 lore raw

Could this be a problem with the xenomai handles (or handled) userspace threads? Is it worth seeing if we can recreate this problem in kernel threads in insmod?

Steven

From: Mark Saiia [mailto:[email protected]
Sent: Monday, November 17, 2008 10:27 AM
To: Gilles Chanteperdrix
Cc: Steven Seeger; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Just a quick update. I haven't had a chance to do as you suggested (2.6.23 w/2.4.5), but will get to it when I have a chance. My previous post was incorrect. The older version of the app was somewhat different. We recreated the environment that was on on the app backup flash with Xenomai 2.6.23.12 w/ Xenomai r3415. The newer version of the app still exhibits floating point errors on this older platform. Yet we ran the simple test program numerous times on the older platform and did not see any incorrect behavior. I am attempting to make a determination as to what in the larger app causes the floating point issue to arise.

Mark

On Fri, Nov 14, 2008 at 12:42 AM, Gilles Chanteperdrix <[email protected]> wrote:

Quoted 3 lines · Mark Saiia

Gilles,

No noticeable difference using 2.4.5 w/ 2.6.26.3. I was testing using

the

Quoted 1 line

app we first noticed the behavior on. I will run the simple test

program

Quoted 1 line

tomorrow, but fully expect to see the erroneous behavior. I also had

the

Quoted 1 line

chance to test the patch on a GX1 board, and noticed the error as

well. We

Quoted 1 line

have a version of the app, that I was testing today, running on

2.6.23.12 w/

Quoted 1 line

Xenomai svn of around February 2008 (I don't have the revision number

in

Quoted 1 line

front of me at the moment) that works properly.

Could you test 2.6.23 with Xenomai 2.4.5? This way we would know if we are looking for a problem in the I-pipe patch or in Xenomai.

--
Gilles.

#17 lore raw
In reply to Mark Saiia

Have there been any thoughts on this issue? We have reverted back to 2.6.23.12 with r3415 for now. Our apps (including the test I posted earlier) work in this older environment. We'd like to use the newer environment because many other bugs have been fixed.

BTW, the older environment works correctly on both our geode boards.

Thanks,

Steven

From: Mark Saiia [mailto:[email protected]
Sent: Monday, November 17, 2008 10:27 AM
To: Gilles Chanteperdrix
Cc: Steven Seeger; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Just a quick update. I haven't had a chance to do as you suggested (2.6.23 w/2.4.5), but will get to it when I have a chance. My previous post was incorrect. The older version of the app was somewhat different. We recreated the environment that was on on the app backup flash with Xenomai 2.6.23.12 w/ Xenomai r3415. The newer version of the app still exhibits floating point errors on this older platform. Yet we ran the simple test program numerous times on the older platform and did not see any incorrect behavior. I am attempting to make a determination as to what in the larger app causes the floating point issue to arise.

Mark

On Fri, Nov 14, 2008 at 12:42 AM, Gilles Chanteperdrix <[email protected]> wrote:

Quoted 3 lines · Mark Saiia

Gilles,

No noticeable difference using 2.4.5 w/ 2.6.26.3. I was testing using

the

Quoted 1 line

app we first noticed the behavior on. I will run the simple test

program

Quoted 1 line

tomorrow, but fully expect to see the erroneous behavior. I also had

the

Quoted 1 line

chance to test the patch on a GX1 board, and noticed the error as

well. We

Quoted 1 line

have a version of the app, that I was testing today, running on

2.6.23.12 w/

Quoted 1 line

Xenomai svn of around February 2008 (I don't have the revision number

in

Quoted 1 line

front of me at the moment) that works properly.

Could you test 2.6.23 with Xenomai 2.4.5? This way we would know if we are looking for a problem in the I-pipe patch or in Xenomai.

--
Gilles.

#18 lore raw
Quoted 8 lines · Steven Seeger

Have there been any thoughts on this issue? We have reverted back to 2.6.23.12 with r3415 for now. Our apps (including the test I posted earlier) work in this older environment. We'd like to use the newer environment because many other bugs have been fixed.

BTW, the older environment works correctly on both our geode boards.

We need to know whether the issue comes from Xenomai or from the I-pipe. So, to know this, we need you to test the 2.6.23 I-pipe patch with Xenomai 2.4.6.1. Unless I am mistaken and forgot to post a mail, I have already asked you this.

Signature · 1 line
                    Gilles.
#19 lore raw

I believe that you did already post this. Just so you know the situation I don't work at Mark's company anymore. I just help them out from time to time. I'm about 800 miles away now so I don't know everything that he's done. I'll be sure to hound him about it today.

Thanks,
Steven

Quoted 16 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Thursday, November 20, 2008 5:44 AM
To: Steven Seeger
Cc: Mark Saiia; Gilles Chanteperdrix; [email protected]
Subject: RE: [Xenomai-help] fpu context switch issue

Quoted 7 lines · Steven Seeger

Have there been any thoughts on this issue? We have reverted back to 2.6.23.12 with r3415 for now. Our apps (including the test I posted earlier) work in this older environment. We'd like to use the newer environment because many other bugs have been fixed.

Quoted 3 lines
Quoted 1 line

BTW, the older environment works correctly on both our geode boards.

We need to know whether the issue comes from Xenomai or from the

I-pipe.

Quoted 3 lines

So, to know this, we need you to test the 2.6.23 I-pipe patch with Xenomai
2.4.6.1. Unless I am mistaken and forgot to post a mail, I have

already

Quoted 4 lines

asked you this.

--
Gilles.

#20 lore raw

I finally had a chance to patch 2.6.23.12 w/ Xenomai-2.4.5. Both the simple test and larger apps worked incorrectly (i.e. had the same floating point
issues as described before). What should the next step be?

Thanks,

Mark

Quoted 38 lines · Steven Seeger

I believe that you did already post this. Just so you know the situation I don't work at Mark's company anymore. I just help them out from time to time. I'm about 800 miles away now so I don't know everything that he's done. I'll be sure to hound him about it today.

Thanks,
Steven

Quoted 16 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Thursday, November 20, 2008 5:44 AM
To: Steven Seeger
Cc: Mark Saiia; Gilles Chanteperdrix; [email protected]
Subject: RE: [Xenomai-help] fpu context switch issue

Quoted 7 lines · Steven Seeger

Have there been any thoughts on this issue? We have reverted back to 2.6.23.12 with r3415 for now. Our apps (including the test I posted earlier) work in this older environment. We'd like to use the newer environment because many other bugs have been fixed.

Quoted 3 lines
Quoted 1 line

BTW, the older environment works correctly on both our geode boards.

We need to know whether the issue comes from Xenomai or from the

I-pipe.

Quoted 3 lines

So, to know this, we need you to test the 2.6.23 I-pipe patch with Xenomai
2.4.6.1. Unless I am mistaken and forgot to post a mail, I have

already

Quoted 4 lines

asked you this.

--
Gilles.

#21 lore raw
Quoted 3 lines · Mark Saiia

I finally had a chance to patch 2.6.23.12 w/ Xenomai-2.4.5. Both the simple test and larger apps worked incorrectly (i.e. had the same floating point
issues as described before). What should the next step be?

The next step is for me to look at the differences between 2.4.5 and the version of Xenomai which works for you and try and imagine what could be the problem.

Signature · 1 line
                                                 Gilles.
#22 lore raw
Quoted 8 lines · Gilles Chanteperdrix
Quoted 3 lines · Mark Saiia

I finally had a chance to patch 2.6.23.12 w/ Xenomai-2.4.5. Both the simple test and larger apps worked incorrectly (i.e. had the same floating point
issues as described before). What should the next step be?

The next step is for me to look at the differences between 2.4.5 and the version of Xenomai which works for you and try and imagine what could be the problem.

Ok. The version you are talking about (r3415) is rather old. Could you try to do a bisection in Xenomai revisions to tell me which commit causes the bug you observe ?

Signature · 1 line
                                                 Gilles.
#23 lore raw
In reply to Steven Seeger

Gilles, I am not sure why Mark didn't email the list yesterday. However, the patch did not work. We still observe the behavior as described. :( We never had this issue on our Geode GX1 board. The LX800 should be a better chip. I continue to tell them to not touch anything with the word "Geode" on it but for some reason they continue to do so.

Steven

#24 lore raw
Quoted 5 lines · Steven Seeger

Gilles, I am not sure why Mark didn't email the list yesterday. However, the patch did not work. We still observe the behavior as described. :( We never had this issue on our Geode GX1 board. The LX800 should be a better chip. I continue to tell them to not touch anything with the word "Geode" on it but for some reason they continue to do so.

I received Mark mail and even answered:

https://mail.gna.org/public/xenomai-help/2008-11/msg00100.html

Signature · 1 line
                                                 Gilles.
#25 lore raw

That's weird. I wonder why I didn't get a copy on the list? I just found the copy to me. Perhaps I should check my inbox instead of my xenomai folder. :) Sorry.

Steven

Quoted 7 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Wednesday, November 12, 2008 6:52 AM
To: Steven Seeger
Cc: Mark Saiia; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 6 lines
Quoted 1 line · Steven Seeger

Gilles, I am not sure why Mark didn't email the list yesterday.

However,

Quoted 1 line

the patch did not work. We still observe the behavior as

described. :(

Quoted 1 line

We never had this issue on our Geode GX1 board. The LX800 should be

a

Quoted 10 lines
Quoted 1 line

better chip. I continue to tell them to not touch anything with the

word

Quoted 1 line

"Geode" on it but for some reason they continue to do so.

I received Mark mail and even answered:

https://mail.gna.org/public/xenomai-help/2008-11/msg00100.html

--
Gilles.

#26 lore raw
In reply to Mark Saiia
Quoted 7 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with 2.6.26.3 AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from my start-up script. I don't know if that is an expected requirement prior to running the test.

Just to understand what I am doing, would you, or anybody else, have a datasheet from AMD with the details of Geode FPU handling ?

Signature · 1 line
                                                 Gilles.
#27 lore raw

Hi Gilles. Please let me know if this is ok. This is the datasheet for the part.

Steven

Quoted 24 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Tuesday, November 04, 2008 2:55 AM
To: Mark Saiia
Cc: Steven Seeger; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 3 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with

2.6.26.3

Quoted 2 lines

AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from

my

Quoted 1 line

start-up script. I don't know if that is an expected requirement

prior to

Quoted 1 line

running the test.

Just to understand what I am doing, would you, or anybody else, have a datasheet from AMD with the details of Geode FPU handling ?

--
Gilles.

#28 lore raw

I've noticed the same erroneous behavior when CONFIG_XENO_HW_FPU is enabled and when it is disabled. I don't know if this information is relevant or not. Is this expected behavior?

Mark Saiia

Quoted 32 lines · Steven Seeger

Hi Gilles. Please let me know if this is ok. This is the datasheet for the part.

Steven

Quoted 24 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Tuesday, November 04, 2008 2:55 AM
To: Mark Saiia
Cc: Steven Seeger; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 3 lines · Mark Saiia

Hello,

The switchtest output is as follows. This was run on 2.4.5 with

2.6.26.3

Quoted 2 lines

AMD Geode LX800 board.
In order to get it to run, I had to remove modprobe xeno_native from

my

Quoted 1 line

start-up script. I don't know if that is an expected requirement

prior to

Quoted 1 line

running the test.

Just to understand what I am doing, would you, or anybody else, have a datasheet from AMD with the details of Geode FPU handling ?

--
Gilles.

#29 lore raw
Quoted 3 lines · Mark Saiia

I've noticed the same erroneous behavior when CONFIG_XENO_HW_FPU is enabled and when it is disabled. I don't know if this information is relevant or not. Is this expected behavior?

No, it should not happen when disabled, you should see messages saying "Invalid use of FPU in Xenomai context at xxxxxx" on the kernel console. That is probably another bug. Is it possible for you to run your example without Xenomai at all ? Just to be sure that we do not hit a Linux bug.

Signature · 1 line
					    Gilles.
#30 lore raw
In reply to Steven Seeger
Quoted 2 lines · Steven Seeger

Hi Gilles. Please let me know if this is ok. This is the datasheet for the part.

Ok, thanks. Unfortunately, the text about finit or fninit is not very detailed. I will try to send a patch anyway.

Signature · 1 line
					    Gilles.
#31 lore raw

Gilles,

Thanks for your effort. Is there a way to make a contribution to the Xenomai project? I should really get the company I'm helping to do that. I have tried to do more to find information on those instructions for the LX800 but I can't find anything.

Steven

Quoted 17 lines

-----Original Message-----
From: Gilles Chanteperdrix [mailto:[email protected]]
Sent: Tuesday, November 04, 2008 12:01 PM
To: Steven Seeger
Cc: Mark Saiia; [email protected]
Subject: Re: [Xenomai-help] fpu context switch issue

Quoted 1 line · Steven Seeger

Hi Gilles. Please let me know if this is ok. This is the datasheet

for

Quoted 1 line

the part.

Ok, thanks. Unfortunately, the text about finit or fninit is not very detailed. I will try to send a patch anyway.

--
Gilles.

#32 lore raw

I modified the example to use pthreads instead of Xenomai and did not observe the erroneous behavior. I kept the same Makefile so all the same libraries were linked in, the only alteration was in the code. (I was using the same Xenomai patched kernel). Furthermore, I did not observe any error messages in the kernel log when FPU was disabled.

Thanks,

Mark