From 8a65066a1118e111cc8a9c3505e5689e53f3e5c4 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 22 Jan 2010 19:58:04 +0000 Subject: [PATCH] vm_soft_fault(): map_page() can fail for B_NO_LOCK areas, since it needs to allocate a page mapping. In that case we do at least have to mark the page not busy again. Furthermore we enforce the minimum page mappings object cache reserve, so we'll have more luck on the next fault. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35241 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/kernel/vm/vm.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 7145377a9c..6ba58da8e2 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -3885,8 +3885,29 @@ vm_soft_fault(VMAddressSpace* addressSpace, addr_t originalAddress, DEBUG_PAGE_ACCESS_END(mappedPage); } - if (mapPage) - map_page(area, context.page, address, newProtection); + if (mapPage) { + if (map_page(area, context.page, address, newProtection) != B_OK) { + // Mapping can only fail, when the page mapping object couldn't + // be allocated. Save for the missing mapping everything is + // fine, though. We'll simply leave and probably fault again. + // To make sure we'll have more luck then, we ensure that the + // minimum object reserve is available. + if (context.page->state == PAGE_STATE_BUSY) + vm_page_set_state(context.page, PAGE_STATE_ACTIVE); + DEBUG_PAGE_ACCESS_END(context.page); + + context.UnlockAll(); + + if (object_cache_reserve(gPageMappingsObjectCache, 1, 0) + != B_OK) { + // Apparently the situation is serious. Let's get ourselves + // killed. + status = B_NO_MEMORY; + } + + break; + } + } DEBUG_PAGE_ACCESS_END(context.page);