diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c index c552cb7..1c6b6e1 100644 --- a/sys/vm/vm_glue.c +++ b/sys/vm/vm_glue.c @@ -94,6 +94,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include /* * System initialization @@ -361,7 +362,7 @@ vm_thread_new(struct thread *td, int pages) vm_offset_t ks; vm_page_t m, ma[KSTACK_MAX_PAGES]; struct kstack_cache_entry *ks_ce; - int i; + int i, retry_count; /* Bounds check */ if (pages <= 1) @@ -388,7 +389,9 @@ vm_thread_new(struct thread *td, int pages) * Allocate an object for the kstack. */ ksobj = vm_object_allocate(OBJT_DEFAULT, pages); - + retry_count = 0; + +retry: /* * Get a kernel virtual address for this thread's kstack. */ @@ -404,6 +407,12 @@ vm_thread_new(struct thread *td, int pages) (pages + KSTACK_GUARD_PAGES) * PAGE_SIZE); #endif if (ks == 0) { + if (retry_count < 7) { + EVENTHANDLER_INVOKE(vm_lowmem, 0); + uma_reclaim(); + retry_count++; + goto retry; + } printf("vm_thread_new: kstack allocation failed\n"); vm_object_deallocate(ksobj); return (0);