commit d75cb9a50c104ad2d50ecd456657ef1cf002810b Author: Mark Johnston Date: Tue Nov 10 21:03:45 2020 -0500 kstack: Hide the guard page from UMA Otherwise we can't determine domain affinity properly. diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index a2500828eae4..c927ede3b45f 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -370,8 +370,10 @@ vm_thread_new(struct thread *td, int pages) pages = KSTACK_MAX_PAGES; ks = 0; - if (pages == kstack_pages && kstack_cache != NULL) + if (pages == kstack_pages && kstack_cache != NULL) { ks = (vm_offset_t)uma_zalloc(kstack_cache, M_NOWAIT); + ks -= KSTACK_GUARD_PAGES * PAGE_SIZE; + } /* * Ensure that kstack objects can draw pages from any memory @@ -401,10 +403,12 @@ vm_thread_dispose(struct thread *td) ks = td->td_kstack; td->td_kstack = 0; td->td_kstack_pages = 0; - if (pages == kstack_pages) + if (pages == kstack_pages) { + ks += KSTACK_GUARD_PAGES * PAGE_SIZE; uma_zfree(kstack_cache, (void *)ks); - else + } else { vm_thread_stack_dispose(ks, pages); + } } /* @@ -440,6 +444,7 @@ static int kstack_import(void *arg, void **store, int cnt, int domain, int flags) { struct domainset *ds; + vm_offset_t ks; int i; if (domain == UMA_ANYDOMAIN) @@ -448,7 +453,8 @@ kstack_import(void *arg, void **store, int cnt, int domain, int flags) ds = DOMAINSET_PREF(domain); for (i = 0; i < cnt; i++) { - store[i] = (void *)vm_thread_stack_create(ds, kstack_pages); + ks = vm_thread_stack_create(ds, kstack_pages); + store[i] = (void *)(ks + KSTACK_GUARD_PAGES * PAGE_SIZE); if (store[i] == NULL) break; } @@ -463,6 +469,7 @@ kstack_release(void *arg, void **store, int cnt) for (i = 0; i < cnt; i++) { ks = (vm_offset_t)store[i]; + ks -= KSTACK_GUARD_PAGES * PAGE_SIZE; vm_thread_stack_dispose(ks, kstack_pages); } }