public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Claus-Justus Heine <ch@dot-heine.de>
To: linux-kernel@vger.kernel.org
Subject: Re: 2.6.0-test4: bug WRT lazy FPU switching and CONFIG_PREEMPT
Date: Mon, 01 Sep 2003 15:15:50 +0200	[thread overview]
Message-ID: <3F534686.1090106@dot-heine.de> (raw)
In-Reply-To: <qCCS.70v.9@gated-at.bofh.it>

Claus-Justus Heine wrote:

[snip]
> diff -u --recursive --new-file linux-2.6.0-test4/include/asm-i386/i387.h linux-2.6.0-test4-mine/include/asm-i386/i387.h
[snip]
> --- linux-2.6.0-test4/include/asm-i386/i387.h    2003-07-27 19:06:54.000000000 +0200
> +++ linux-2.6.0-test4-mine/include/asm-i386/i387.h    2003-08-31 15:39:04.000000000 +0200
> @@ -30,7 +30,7 @@
>  static inline void __save_init_fpu( struct task_struct *tsk )
>  {
>      if ( cpu_has_fxsr ) {
> -        asm volatile( "fxsave %0 ; fnclex"
> +        asm volatile( "fxsave %0 ; fclex"

I'm sorry, changing "fnclex" to "fclex" was a stupid idea, can lead to deadlocks. So that
patch should have looked like this:

#########################################################################################################################
diff -u --recursive --new-file linux-2.6.0-test4/arch/i386/kernel/traps.c linux-2.6.0-test4-mine/arch/i386/kernel/traps.c
--- linux-2.6.0-test4/arch/i386/kernel/traps.c    2003-08-31 15:22:42.000000000 +0200
+++ linux-2.6.0-test4-mine/arch/i386/kernel/traps.c    2003-08-31 15:35:49.000000000 +0200
@@ -605,7 +605,10 @@
       * Save the info for the exception handler and clear the error.
       */
      task = current;
-    save_init_fpu(task);
+    /* don't trigger an unnecessary math_state_restore() */
+    if (task->thread_info->status & TS_USEDFPU) {
+        save_init_fpu(task);
+    }
      task->thread.trap_no = 16;
      task->thread.error_code = 0;
      info.si_signo = SIGFPE;
@@ -667,7 +670,10 @@
       * Save the info for the exception handler and clear the error.
       */
      task = current;
-    save_init_fpu(task);
+    /* don't trigger an unnecessary math_state_restore() */
+    if (task->thread_info->status & TS_USEDFPU) {
+        save_init_fpu(task);
+    }
      task->thread.trap_no = 19;
      task->thread.error_code = 0;
      info.si_signo = SIGFPE;
diff -u --recursive --new-file linux-2.6.0-test4/include/asm-i386/i387.h linux-2.6.0-test4-mine/include/asm-i386/i387.h
--- linux-2.6.0-test4/include/asm-i386/i387.h    2003-07-27 19:06:54.000000000 +0200
+++ linux-2.6.0-test4-mine/include/asm-i386/i387.h    2003-08-31 15:39:04.000000000 +0200
@@ -41,8 +41,10 @@

  static inline void save_init_fpu( struct task_struct *tsk )
  {
+    preempt_disable();
      __save_init_fpu(tsk);
      stts();
+    preempt_enable_no_resched();
  }


@@ -53,11 +55,13 @@

  #define clear_fpu( tsk )                    \
  do {                                \
+    preempt_disable();                    \
      if ((tsk)->thread_info->status & TS_USEDFPU) {        \
          asm volatile("fwait");                \
          (tsk)->thread_info->status &= ~TS_USEDFPU;    \
          stts();                        \
      }                            \
+    preempt_enable_no_resched();                \
  } while (0)

  /*
##########################################################################################################################################



       reply	other threads:[~2003-09-01 13:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <qCCS.70v.9@gated-at.bofh.it>
2003-09-01 13:15 ` Claus-Justus Heine [this message]
2003-08-31 15:42 2.6.0-test4: bug WRT lazy FPU switching and CONFIG_PREEMPT Claus-Justus Heine

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=3F534686.1090106@dot-heine.de \
    --to=ch@dot-heine.de \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox