From 91af25d302d49ee3d83cb554e14954082e2ecf28 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Mon, 21 Jun 2010 18:22:42 +0000 Subject: [PATCH] vm_create_anonymous_area(): * Fixed check: If a low *or* high address restriction is given, we need to force B_CONTIGUOUS wiring. * Optimization: Contiguous single-page allocation can be allocated as full-lock, if the no low/high address restrictions are given. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37203 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index f05784243f..42fcd41a25 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -1096,8 +1096,11 @@ vm_create_anonymous_area(team_id team, const char *name, addr_t size, return B_BAD_VALUE; } + // If low or high physical address restrictions are given, we force + // B_CONTIGUOUS wiring, since only then we'll use + // vm_page_allocate_page_run() which deals with those restrictions. if (physicalAddressRestrictions->low_address != 0 - && physicalAddressRestrictions->high_address != 0) { + || physicalAddressRestrictions->high_address != 0) { wiring = B_CONTIGUOUS; } @@ -1137,6 +1140,14 @@ vm_create_anonymous_area(team_id team, const char *name, addr_t size, return B_BAD_VALUE; } + // Optimization: For a single-page contiguous allocation without low/high + // memory restriction B_FULL_LOCK wiring suffices. + if (wiring == B_CONTIGUOUS && size == B_PAGE_SIZE + && physicalAddressRestrictions->low_address == 0 + && physicalAddressRestrictions->high_address == 0) { + wiring = B_FULL_LOCK; + } + // For full lock or contiguous areas we're also going to map the pages and // thus need to reserve pages for the mapping backend upfront. addr_t reservedMapPages = 0;