From 13fa4c845ac5f1e2167a30fcc4cee3925ec6619e Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 6 May 2010 14:59:14 +0000 Subject: [PATCH] * Introduced new area creation flag CREATE_AREA_DONT_COMMIT_MEMORY. map_backing_store() doesn't commit memory when this flag is given. * Used the new flag vm_copy_area(): We no longer commit memory for read-only areas. This prevents read-only mapped files from suddenly requiring memory after fork(). Might improve the situation on machines with very little RAM a bit. We should probably mark writable copies over-committing, since the usual case is fork() + exec() where the child normally doesn't need more than a few pages until calling exec(). That would significantly reduce the memory requirement for jamming the Haiku tree. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36651 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/private/kernel/vm/vm.h | 1 + src/system/kernel/vm/vm.cpp | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/headers/private/kernel/vm/vm.h b/headers/private/kernel/vm/vm.h index 0c79ceecc5..352a89cf45 100644 --- a/headers/private/kernel/vm/vm.h +++ b/headers/private/kernel/vm/vm.h @@ -32,6 +32,7 @@ struct VMPageWiringInfo; #define CREATE_AREA_UNMAP_ADDRESS_RANGE 0x02 #define CREATE_AREA_DONT_CLEAR 0x04 #define CREATE_AREA_PRIORITY_VIP 0x08 +#define CREATE_AREA_DONT_COMMIT_MEMORY 0x10 // memory/page allocation priorities #define VM_PRIORITY_USER 0 diff --git a/src/system/kernel/vm/vm.cpp b/src/system/kernel/vm/vm.cpp index 0eee0f8c71..c331be2731 100644 --- a/src/system/kernel/vm/vm.cpp +++ b/src/system/kernel/vm/vm.cpp @@ -794,9 +794,11 @@ map_backing_store(VMAddressSpace* addressSpace, VMCache* cache, cache = newCache; } - status = cache->SetMinimalCommitment(size, priority); - if (status != B_OK) - goto err2; + if ((flags & CREATE_AREA_DONT_COMMIT_MEMORY) == 0) { + status = cache->SetMinimalCommitment(size, priority); + if (status != B_OK) + goto err2; + } // check to see if this address space has entered DELETE state if (addressSpace->IsBeingDeleted()) { @@ -2229,7 +2231,7 @@ vm_copy_area(team_id team, const char* name, void** _address, status = map_backing_store(targetAddressSpace, cache, _address, source->cache_offset, source->Size(), addressSpec, source->wiring, protection, sharedArea ? REGION_NO_PRIVATE_MAP : REGION_PRIVATE_MAP, - &target, name, 0, true); + &target, name, writableCopy ? 0 : CREATE_AREA_DONT_COMMIT_MEMORY, true); if (status < B_OK) return status;