From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Steven Seeger <sseeger@domain.hid>
Cc: xenomai@xenomai.org, Adeos <adeos-main@gna.org>
Subject: Re: [Xenomai-help] fpu issue
Date: Mon, 26 Jan 2009 16:13:25 +0000 [thread overview]
Message-ID: <497DE125.5020402@domain.hid> (raw)
In-Reply-To: <51CAD0CE1504444DBE77CBBE51A0135D5907E9@domain.hid>
Steven Seeger wrote:
> It is being called a lot. Running my test with the break in both loops
> yields approximately 60 calls to it. Half of those are called even
> before i387.c's init_fpu().
For the records: we found a solution to this FPU issue. The issue was
two-fold:
- when xenomai was preempting some linux kernel code which has called
kernel_fpu_begin, it was saving the current FPU context over the current
thread user-space FPU backup area, erasing its value previously saved by
kernel_fpu_begin();
- xenomai could preempt the linux kernel anywhere within the
kernel_fpu_begin function, which caused it to observe an incoherent
state (namely incoherent values of
current_thread_info()->status & TS_USEDFPU and TS bit in CR0).
These issues were easy to observe on Geode, because Linux on these
processors use MMX, thus kernel_fpu_begin routinely.
So, the following patch should be integrated into the I-pipe patch:
diff --git a/include/asm-x86/i387.h b/include/asm-x86/i387.h
index 56d00e3..e850fa1 100644
--- a/include/asm-x86/i387.h
+++ b/include/asm-x86/i387.h
@@ -222,11 +222,14 @@ static inline void __clear_fpu(struct task_struct
*tsk)
static inline void kernel_fpu_begin(void)
{
struct thread_info *me = current_thread_info();
+ unsigned long flags;
preempt_disable();
+ local_irq_save_hw_cond(flags);
if (me->status & TS_USEDFPU)
__save_init_fpu(me->task);
else
clts();
+ local_irq_restore_hw_cond(flags);
}
static inline void kernel_fpu_end(void)
And the following patch should be applied to Xenomai:
Index: include/asm-x86/bits/pod_32.h
===================================================================
--- include/asm-x86/bits/pod_32.h (revision 4572)
+++ include/asm-x86/bits/pod_32.h (working copy)
@@ -63,7 +63,12 @@ static inline void xnarch_leave_root(xna
rootcb->ts_usedfpu = wrap_test_fpu_used(current) != 0;
rootcb->cr0_ts = (read_cr0() & 8) != 0;
/* So that xnarch_save_fpu() will operate on the right FPU area. */
- rootcb->fpup = x86_fpustate_ptr(&rootcb->user_task->thread);
+ if (rootcb->cr0_ts || rootcb->ts_usedfpu)
+ rootcb->fpup = x86_fpustate_ptr(&rootcb->user_task->thread);
+ else
+ /* the kernel is currently using fpu in kernel-space, do not
+ clobber the user-space fpu backup area. */
+ rootcb->fpup = &rootcb->i387;
}
#define xnarch_enter_root(rootcb) do { } while(0)
--
Gilles.
next prev parent reply other threads:[~2009-01-26 16:13 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-20 4:25 [Xenomai-help] fpu issue Steven Seeger
2009-01-20 7:20 ` Gilles Chanteperdrix
2009-01-20 14:34 ` Steven Seeger
2009-01-20 14:49 ` Gilles Chanteperdrix
2009-01-20 14:55 ` Steven Seeger
2009-01-20 14:56 ` Gilles Chanteperdrix
2009-01-21 0:40 ` Steven Seeger
2009-01-21 9:28 ` Gilles Chanteperdrix
2009-01-21 13:30 ` Steven Seeger
2009-01-21 16:42 ` Steven Seeger
2009-01-21 16:48 ` Gilles Chanteperdrix
2009-01-21 17:07 ` Steven Seeger
2009-01-21 17:11 ` Gilles Chanteperdrix
2009-01-21 17:16 ` Steven Seeger
2009-01-21 17:42 ` Steven Seeger
2009-01-21 18:01 ` Gilles Chanteperdrix
2009-01-21 19:41 ` Steven Seeger
2009-01-21 19:48 ` Gilles Chanteperdrix
2009-01-21 20:05 ` Steven Seeger
2009-01-21 20:08 ` Steven Seeger
2009-01-21 20:45 ` Steven Seeger
2009-01-21 20:47 ` Steven Seeger
2009-01-21 21:13 ` Gilles Chanteperdrix
2009-01-21 21:20 ` Steven Seeger
2009-01-21 21:26 ` Gilles Chanteperdrix
2009-01-21 21:27 ` Steven Seeger
2009-01-21 21:44 ` Steven Seeger
2009-01-21 21:56 ` Gilles Chanteperdrix
2009-01-21 21:57 ` Steven Seeger
2009-01-26 16:13 ` Gilles Chanteperdrix [this message]
2009-01-27 10:28 ` [Xenomai-help] fpu issue on PPC ? roderik.wildenburg
2009-01-27 10:35 ` Gilles Chanteperdrix
2009-01-21 16:43 ` [Xenomai-help] fpu issue Steven Seeger
-- strict thread matches above, loose matches on Subject: below --
2008-02-09 1:36 Steven Seeger
2008-02-09 13:29 ` Gilles Chanteperdrix
2008-02-10 15:32 ` Steven Seeger
2008-02-10 15:41 ` Gilles Chanteperdrix
2008-02-10 16:36 ` Gilles Chanteperdrix
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=497DE125.5020402@domain.hid \
--to=gilles.chanteperdrix@xenomai.org \
--cc=adeos-main@gna.org \
--cc=sseeger@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.