From 43d2ad0d2043a278a2772519013f25a0bc4b067f Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Sat, 7 Jul 2012 08:10:04 +0000 Subject: Allocate kernel thread stacks out of kmem_map The kernel submaps eat most of the available kernel space. Using the main kernel map for thread stacks sometimes lead to exhaustion when many threads are created. Use kmem_map instead to increase this limit. * kern/thread.c (stack_alloc): Use kmem_map instead of kernel_map for stack allocation. (stack_collect): Likewise for release. --- kern/thread.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'kern/thread.c') diff --git a/kern/thread.c b/kern/thread.c index 27faf434..d279bc82 100644 --- a/kern/thread.c +++ b/kern/thread.c @@ -208,7 +208,7 @@ void stack_alloc( * addresses of a stack given an address in the middle. */ - if (kmem_alloc_aligned(kernel_map, &stack, KERNEL_STACK_SIZE) + if (kmem_alloc_aligned(kmem_map, &stack, KERNEL_STACK_SIZE) != KERN_SUCCESS) panic("stack_alloc"); @@ -268,7 +268,7 @@ void stack_collect(void) #if MACH_DEBUG stack_finalize(stack); #endif /* MACH_DEBUG */ - kmem_free(kernel_map, stack, KERNEL_STACK_SIZE); + kmem_free(kmem_map, stack, KERNEL_STACK_SIZE); s = splsched(); stack_lock(); -- cgit v1.2.3