aboutsummaryrefslogtreecommitdiff
path: root/sys/i386
diff options
context:
space:
mode:
authorEric van Gyzen <vangyzen@FreeBSD.org>2020-06-12 21:10:45 +0000
committerEric van Gyzen <vangyzen@FreeBSD.org>2020-06-12 21:10:45 +0000
commit674cbe79086dd950e0df39dbb2d211af0b4c54f1 (patch)
tree0d30d49eb2c739b82399974bd0cee6928f22a3de /sys/i386
parentf092a3c71c314592f996a809c8cc40f21be50065 (diff)
downloadsrc-674cbe79086dd950e0df39dbb2d211af0b4c54f1.tar.gz
src-674cbe79086dd950e0df39dbb2d211af0b4c54f1.zip
FPU init: Do potentially blocking operations before disabling interrupts
In particular, uma_zcreate creates sysctl oids, which locks an sx lock, which uses IPIs under contention. IPIs tend not to work very well when interrupts are disabled. Who knew, right? Reviewed by: cem kib MFC after: 2 weeks Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D25098
Notes
Notes: svn path=/head/; revision=362119
Diffstat (limited to 'sys/i386')
-rw-r--r--sys/i386/i386/npx.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/sys/i386/i386/npx.c b/sys/i386/i386/npx.c
index 7c3496575199..fc03de27d407 100644
--- a/sys/i386/i386/npx.c
+++ b/sys/i386/i386/npx.c
@@ -479,8 +479,21 @@ npxinitstate(void *arg __unused)
if (!hw_float)
return;
+ /* Do potentially blocking operations before disabling interrupts. */
+ fpu_save_area_zone = uma_zcreate("FPU_save_area",
+ cpu_max_ext_state_size, NULL, NULL, NULL, NULL,
+ XSAVE_AREA_ALIGN - 1, 0);
npx_initialstate = malloc(cpu_max_ext_state_size, M_DEVBUF,
M_WAITOK | M_ZERO);
+ if (use_xsave) {
+ if (xsave_mask >> 32 != 0)
+ max_ext_n = fls(xsave_mask >> 32) + 32;
+ else
+ max_ext_n = fls(xsave_mask);
+ xsave_area_desc = malloc(max_ext_n * sizeof(struct
+ xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO);
+ }
+
saveintr = intr_disable();
stop_emulating();
@@ -522,12 +535,6 @@ npxinitstate(void *arg __unused)
offsetof(struct xstate_hdr, xstate_bv));
*xstate_bv = XFEATURE_ENABLED_X87 | XFEATURE_ENABLED_SSE;
- if (xsave_mask >> 32 != 0)
- max_ext_n = fls(xsave_mask >> 32) + 32;
- else
- max_ext_n = fls(xsave_mask);
- xsave_area_desc = malloc(max_ext_n * sizeof(struct
- xsave_area_elm_descr), M_DEVBUF, M_WAITOK | M_ZERO);
/* x87 state */
xsave_area_desc[0].offset = 0;
xsave_area_desc[0].size = 160;
@@ -542,10 +549,6 @@ npxinitstate(void *arg __unused)
}
}
- fpu_save_area_zone = uma_zcreate("FPU_save_area",
- cpu_max_ext_state_size, NULL, NULL, NULL, NULL,
- XSAVE_AREA_ALIGN - 1, 0);
-
start_emulating();
intr_restore(saveintr);
}