diff options
author | pjd <pjd@FreeBSD.org> | 2008-01-10 08:36:38 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2008-01-10 08:36:38 +0000 |
commit | 340995c5fdb23429629907090fd314c0f6067cfe (patch) | |
tree | bbd1a7d4fb69e2d0798e1c1f04c1a09423bc0772 /sys/vm | |
parent | 257b751f99eba76656108712078588eab0d95954 (diff) | |
download | FreeBSD-src-340995c5fdb23429629907090fd314c0f6067cfe.zip FreeBSD-src-340995c5fdb23429629907090fd314c0f6067cfe.tar.gz |
When one tries to allocate memory with the M_WAITOK flag and we are short in
address space in kmem map call vm_lowmem event in a loop and wait a bit for
subsystems to reclaim some memory which in turn will reclaim address space as
well.
Note, this is a work-around.
Reviewed by: alc
Approved by: alc
MFC after: 3 days
Diffstat (limited to 'sys/vm')
-rw-r--r-- | sys/vm/vm_kern.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c index 44694f5..3de6b1d 100644 --- a/sys/vm/vm_kern.c +++ b/sys/vm/vm_kern.c @@ -296,14 +296,21 @@ kmem_malloc(map, size, flags) vm_map_lock(map); if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { vm_map_unlock(map); - if ((flags & M_NOWAIT) == 0) { - EVENTHANDLER_INVOKE(vm_lowmem, 0); - uma_reclaim(); - vm_map_lock(map); - if (vm_map_findspace(map, vm_map_min(map), size, &addr)) { + if ((flags & M_NOWAIT) == 0) { + for (i = 0; i < 8; i++) { + EVENTHANDLER_INVOKE(vm_lowmem, 0); + uma_reclaim(); + vm_map_lock(map); + if (vm_map_findspace(map, vm_map_min(map), + size, &addr) == 0) { + break; + } vm_map_unlock(map); + tsleep(&i, 0, "nokva", (hz / 4) * (i + 1)); + } + if (i == 8) { panic("kmem_malloc(%ld): kmem_map too small: %ld total allocated", - (long)size, (long)map->size); + (long)size, (long)map->size); } } else { return (0); |