From 75944832cea8d4811315814655485a97d4b9e6d1 Mon Sep 17 00:00:00 2001 From: alc Date: Thu, 26 Nov 2015 19:12:18 +0000 Subject: Correct an error in vm_reserv_reclaim_contig(). In the highly unusual case that the reservation contained "low", the starting position in the popmap for the free page search was incorrectly calculated. The most likely (and visible) symptom of this error was the assertion failure, "vm_reserv_reclaim_contig: pa is too low". --- sys/vm/vm_reserv.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'sys/vm/vm_reserv.c') diff --git a/sys/vm/vm_reserv.c b/sys/vm/vm_reserv.c index 34e69e1..8f34b31 100644 --- a/sys/vm/vm_reserv.c +++ b/sys/vm/vm_reserv.c @@ -971,7 +971,7 @@ vm_reserv_reclaim_contig(u_long npages, vm_paddr_t low, vm_paddr_t high, { vm_paddr_t pa, size; vm_reserv_t rv; - int hi, i, lo, next_free; + int hi, i, lo, low_index, next_free; mtx_assert(&vm_page_queue_free_mtx, MA_OWNED); if (npages > VM_LEVEL_0_NPAGES - 1) @@ -990,8 +990,9 @@ vm_reserv_reclaim_contig(u_long npages, vm_paddr_t low, vm_paddr_t high, } if (pa < low) { /* Start the search for free pages at "low". */ - i = (low - pa) / NBPOPMAP; - hi = (low - pa) % NBPOPMAP; + low_index = (low + PAGE_MASK - pa) >> PAGE_SHIFT; + i = low_index / NBPOPMAP; + hi = low_index % NBPOPMAP; } else i = hi = 0; do { -- cgit v1.1