diff options
author | Zheng Da <zhengda1936@gmail.com> | 2009-11-11 16:09:41 +0100 |
---|---|---|
committer | Zheng Da <zhengda1936@gmail.com> | 2009-11-11 16:09:41 +0100 |
commit | 5c56c93c5ff8c3cc999a25ad0f38bcc73d7e76e8 (patch) | |
tree | 8b1af43be5a22ed60058c971049a50889c65a199 | |
parent | e081496863b8ec02f10c71dd41a30cf75d01162c (diff) |
Fix a bug in vm_page_grab_contiguous_pages.
* vm/vm_resident.c (vm_page_grab_contiguous_pages): Maintain the free vm page queue correctly.
-rw-r--r-- | vm/vm_resident.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/vm/vm_resident.c b/vm/vm_resident.c index 5470368..0d5d650 100644 --- a/vm/vm_resident.c +++ b/vm/vm_resident.c @@ -935,7 +935,7 @@ vm_page_grab_contiguous_pages( register int first_set; int size, alloc_size; kern_return_t ret; - vm_page_t mem, prevmem; + vm_page_t mem, *prevmemp; #ifndef NBBY #define NBBY 8 /* size in bits of sizeof()`s unity */ @@ -1088,7 +1088,7 @@ found_em: /* running pointers */ mem = vm_page_queue_free; - prevmem = VM_PAGE_NULL; + prevmemp = &vm_page_queue_free; while (mem) { @@ -1098,8 +1098,7 @@ found_em: if ((addr >= first_phys) && (addr < last_phys)) { - if (prevmem) - prevmem->pageq.next = mem->pageq.next; + *prevmemp = mem->pageq.next; pages[(addr - first_phys) >> PAGE_SHIFT] = mem; mem->free = FALSE; mem->extcounted = mem->external = external; @@ -1108,7 +1107,7 @@ found_em: */ if (--npages == 0) break; } else - prevmem = mem; + prevmemp = &mem->pageq.next; mem = (vm_page_t) mem->pageq.next; } |