svn commit: r335132 - in head/sys: amd64/amd64 i386/i386
Konstantin Belousov
kib at FreeBSD.org
Thu Jun 14 11:09:53 UTC 2018
Author: kib
Date: Thu Jun 14 11:09:51 2018
New Revision: 335132
URL: https://svnweb.freebsd.org/changeset/base/335132
Log:
Reorganize code flow in fpudna()/npxdna() to highlight the critical
section scope. Sprinkle __predict_false() for conditions known to
never occur or occur only on rare platforms.
Sponsored by: The FreeBSD Foundation
Modified:
head/sys/amd64/amd64/fpu.c
head/sys/i386/i386/npx.c
Modified: head/sys/amd64/amd64/fpu.c
==============================================================================
--- head/sys/amd64/amd64/fpu.c Thu Jun 14 10:33:26 2018 (r335131)
+++ head/sys/amd64/amd64/fpu.c Thu Jun 14 11:09:51 2018 (r335132)
@@ -722,7 +722,7 @@ fpudna(void)
KASSERT((curpcb->pcb_flags & PCB_FPUNOSAVE) == 0,
("fpudna while in fpu_kern_enter(FPU_KERN_NOCTX)"));
- if (PCPU_GET(fpcurthread) == td) {
+ if (__predict_false(PCPU_GET(fpcurthread) == td)) {
/*
* Some virtual machines seems to set %cr0.TS at
* arbitrary moments. Silently clear the TS bit
@@ -730,15 +730,15 @@ fpudna(void)
* mode.
*/
stop_emulating();
- critical_exit();
- return;
+ } else {
+ if (__predict_false(PCPU_GET(fpcurthread) != NULL)) {
+ panic(
+ "fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n",
+ PCPU_GET(fpcurthread),
+ PCPU_GET(fpcurthread)->td_tid, td, td->td_tid);
+ }
+ restore_fpu_curthread(td);
}
- if (PCPU_GET(fpcurthread) != NULL) {
- panic("fpudna: fpcurthread = %p (%d), curthread = %p (%d)\n",
- PCPU_GET(fpcurthread), PCPU_GET(fpcurthread)->td_tid,
- td, td->td_tid);
- }
- restore_fpu_curthread(td);
critical_exit();
}
Modified: head/sys/i386/i386/npx.c
==============================================================================
--- head/sys/i386/i386/npx.c Thu Jun 14 10:33:26 2018 (r335131)
+++ head/sys/i386/i386/npx.c Thu Jun 14 11:09:51 2018 (r335132)
@@ -835,7 +835,7 @@ npxdna(void)
return (0);
td = curthread;
critical_enter();
- if (PCPU_GET(fpcurthread) == td) {
+ if (__predict_false(PCPU_GET(fpcurthread) == td)) {
/*
* Some virtual machines seems to set %cr0.TS at
* arbitrary moments. Silently clear the TS bit
@@ -843,19 +843,18 @@ npxdna(void)
* mode.
*/
stop_emulating();
- critical_exit();
- return (1);
+ } else {
+ if (__predict_false(PCPU_GET(fpcurthread) != NULL)) {
+ printf(
+ "npxdna: fpcurthread = %p (%d), curthread = %p (%d)\n",
+ PCPU_GET(fpcurthread),
+ PCPU_GET(fpcurthread)->td_proc->p_pid,
+ td, td->td_proc->p_pid);
+ panic("npxdna");
+ }
+ restore_npx_curthread(td, td->td_pcb);
}
- if (PCPU_GET(fpcurthread) != NULL) {
- printf("npxdna: fpcurthread = %p (%d), curthread = %p (%d)\n",
- PCPU_GET(fpcurthread),
- PCPU_GET(fpcurthread)->td_proc->p_pid,
- td, td->td_proc->p_pid);
- panic("npxdna");
- }
- restore_npx_curthread(td, td->td_pcb);
critical_exit();
-
return (1);
}
More information about the svn-src-all
mailing list