aboutsummaryrefslogtreecommitdiff
path: root/sys/vm
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2018-09-19 16:02:33 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2018-09-19 16:02:33 +0000
commitc035292545cf7b7ce74236d87ef1b2f985bd0cb7 (patch)
treee17245e7d4f34fb2cfeac11f62c48c07b47b0239 /sys/vm
parent215aa93033a2e7b9db61d989c51062ff82175bb2 (diff)
downloadsrc-c035292545cf7b7ce74236d87ef1b2f985bd0cb7.tar.gz
src-c035292545cf7b7ce74236d87ef1b2f985bd0cb7.zip
vm: check for empty kstack cache before locking
The current cache logic checks the total number of stacks in the kernel, which even on small boxes significantly exceeds the 128 limit (e.g. an 8-way box with zfs has almost 800 stacks allocated). Stacks are cached earlier for each main thread. As a result the code is rarely executed, but when it is then (on boxes like the above) it always fails. Since there are no provisions made for NUMA and release time is approaching, just do a quick check to avoid acquiring the lock. Approved by: re (kib)
Notes
Notes: svn path=/head/; revision=338802
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/vm_glue.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index 832dbce324ef..beccb31f0b64 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -327,7 +327,7 @@ vm_thread_new(struct thread *td, int pages)
else if (pages > KSTACK_MAX_PAGES)
pages = KSTACK_MAX_PAGES;
- if (pages == kstack_pages) {
+ if (pages == kstack_pages && kstack_cache != NULL) {
mtx_lock(&kstack_cache_mtx);
if (kstack_cache != NULL) {
ks_ce = kstack_cache;