summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_kthread.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2009-09-01 11:41:51 +0000
committerkib <kib@FreeBSD.org>2009-09-01 11:41:51 +0000
commitbae5df8cbb88dd3a3930f1c4f5281e1782961a36 (patch)
treecba3987f868648d34d432849ac13b04378d79b4c /sys/kern/kern_kthread.c
parentce36458bc885a611a3164145f2e49ae15cfa896a (diff)
downloadFreeBSD-src-bae5df8cbb88dd3a3930f1c4f5281e1782961a36.zip
FreeBSD-src-bae5df8cbb88dd3a3930f1c4f5281e1782961a36.tar.gz
Reintroduce the r196640, after fixing the problem with my testing.
Remove the altkstacks, instead instantiate threads with kernel stack allocated with the right size from the start. For the thread that has kernel stack cached, verify that requested stack size is equial to the actual, and reallocate the stack if sizes differ [1]. This fixes the bug introduced by r173361 that was committed several days after r173004 and consisted of kthread_add(9) ignoring the non-default kernel stack size. Also, r173361 removed the caching of the kernel stacks for a non-first thread in the process. Introduce separate kernel stack cache that keeps some limited amount of preallocated kernel stacks to lower the latency of thread allocation. Add vm_lowmem handler to prune the cache on low memory condition. This way, system with reasonable amount of the threads get lower latency of thread creation, while still not exhausting significant portion of KVA for unused kstacks. Submitted by: peter [1] Discussed with: jhb, julian, peter Reviewed by: jhb Tested by: pho (and retested according to new test scenarious) MFC after: 1 week
Diffstat (limited to 'sys/kern/kern_kthread.c')
-rw-r--r--sys/kern/kern_kthread.c5
1 files changed, 1 insertions, 4 deletions
diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c
index 1092832..3c5248e 100644
--- a/sys/kern/kern_kthread.c
+++ b/sys/kern/kern_kthread.c
@@ -256,7 +256,7 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
}
/* Initialize our new td */
- newtd = thread_alloc();
+ newtd = thread_alloc(pages);
if (newtd == NULL)
return (ENOMEM);
@@ -282,9 +282,6 @@ kthread_add(void (*func)(void *), void *arg, struct proc *p,
newtd->td_pflags |= TDP_KTHREAD;
newtd->td_ucred = crhold(p->p_ucred);
- /* Allocate and switch to an alternate kstack if specified. */
- if (pages != 0)
- vm_thread_new_altkstack(newtd, pages);
/* this code almost the same as create_thread() in kern_thr.c */
PROC_LOCK(p);
OpenPOWER on IntegriCloud