Author: bonefish Date: 2010-04-30 14:09:43 +0200 (Fri, 30 Apr 2010) New Revision: 36552 Changeset: http://dev.haiku-os.org/changeset/36552/haiku Ticket: http://dev.haiku-os.org/ticket/5822 Modified: haiku/trunk/src/system/runtime_loader/images.cpp Log: Map read-only segments over-committing for the relocation. This prevents the kernel from committing memory for all read-only segments until we're done relocating. This allows Haiku to boot on machines with less RAM and swap disabled. At least in qemu I could boot with 100 MB and start WebPositive. Probably fixed #5822. Modified: haiku/trunk/src/system/runtime_loader/images.cpp =================================================================== --- haiku/trunk/src/system/runtime_loader/images.cpp 2010-04-30 12:02:33 UTC (rev 36551) +++ haiku/trunk/src/system/runtime_loader/images.cpp 2010-04-30 12:09:43 UTC (rev 36552) @@ -1,5 +1,5 @@ /* - * Copyright 2008-2009, Ingo Weinhold, ingo_weinhold@xxxxxxx + * Copyright 2008-2010, Ingo Weinhold, ingo_weinhold@xxxxxxx * Copyright 2003-2009, Axel Dörfler, axeld@xxxxxxxxxxxxxxxxx * Distributed under the terms of the MIT License. * @@ -354,11 +354,20 @@ return image->regions[i].id; } } else { + // Map all segments r/w first -- write access might be needed for + // relocations. When we've done with those we change the protection + // of read-only segments back to read-only. We map those segments + // over-committing, since quite likely only a relatively small + // number of pages needs to be touched and we want to avoid a lot + // of memory to be committed for them temporarily, just because we + // have to write map them. + uint32 protection = B_READ_AREA | B_WRITE_AREA + | ((image->regions[i].flags & RFLAG_RW) != 0 + ? 0 : B_OVERCOMMITTING_AREA); image->regions[i].id = _kern_map_file(regionName, (void**)&loadAddress, B_EXACT_ADDRESS, - image->regions[i].vmsize, B_READ_AREA | B_WRITE_AREA, - REGION_PRIVATE_MAP, false, fd, - PAGE_BASE(image->regions[i].fdstart)); + image->regions[i].vmsize, protection, REGION_PRIVATE_MAP, false, + fd, PAGE_BASE(image->regions[i].fdstart)); if (image->regions[i].id < 0) { _kern_unreserve_address_range(reservedAddress, reservedSize);