-------- Original Message -------- Subject: [PATCH] try harder to grab memory by using vm_contig_grow_cache() Date: 09.03.2012 23:00 From: Andriy Gapon <[email protected]> To: Bernhard Froehlich <[email protected]>
... this behavior should match what contigmalloc(M_NOWAIT) does. Signed-off-by: Andriy Gapon <[email protected]> --- .../Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c b/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c index 75427ab..bf68c83 100644 --- a/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c +++ b/src/VBox/Runtime/r0drv/freebsd/memobj-r0drv-freebsd.c @@ -191,16 +191,33 @@ static vm_page_t rtR0MemObjFreeBSDContigPhysAllocHelper(vm_object_t pObject, vm_ u_long uAlignment, bool fWire) { vm_page_t pPages; + int tries = 0; + #if __FreeBSD_version > 1000000 int fFlags = VM_ALLOC_INTERRUPT | VM_ALLOC_NOBUSY; if (fWire) fFlags |= VM_ALLOC_WIRED; - VM_OBJECT_LOCK(pObject); - pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0, VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT); - VM_OBJECT_UNLOCK(pObject); + while (1) + { + VM_OBJECT_LOCK(pObject); + pPages = vm_page_alloc_contig(pObject, iPIndex, fFlags, cPages, 0, + VmPhysAddrHigh, uAlignment, 0, VM_MEMATTR_DEFAULT); + VM_OBJECT_UNLOCK(pObject); + if (pPages || tries >= 1) + break; + vm_contig_grow_cache(tries, 0, VmPhysAddrHigh); + tries++; + } return pPages; #else - pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0); + while (1) + { + pPages = vm_phys_alloc_contig(cPages, 0, VmPhysAddrHigh, uAlignment, 0); + if (pPages || tries >= 1) + break; + vm_contig_grow_cache(tries, 0, VmPhysAddrHigh); + tries++; + } if (!pPages) return pPages; VM_OBJECT_LOCK(pObject); _______________________________________________ vbox-dev mailing list [email protected] https://www.virtualbox.org/mailman/listinfo/vbox-dev
