VMAnonymous[NoSwap]Cache, overcommitting mode:
* Commit(): Unreserve memory when asked to shrink the commitment. * Fault(): The whole logic is flawed, since this is always called by vm_soft_fault(), even, if the page is finally mapped from a lower cache. Now we do at least limit our commitment to (page_count + 1) * B_PAGE_SIZE instead of always reserving memory for another page. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@36551 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -527,8 +527,9 @@ VMAnonymousCache::Commit(off_t size, int priority)
|
||||
{
|
||||
TRACE("%p->VMAnonymousCache::Commit(%lld)\n", this, size);
|
||||
|
||||
// if we can overcommit, we don't commit here, but in anonymous_fault()
|
||||
if (fCanOvercommit) {
|
||||
// If we can overcommit, we don't commit here, but in Fault(). We always
|
||||
// unreserve memory, if we're asked to shrink our commitment, though.
|
||||
if (fCanOvercommit && size > committed_size) {
|
||||
if (fHasPrecommitted)
|
||||
return B_OK;
|
||||
|
||||
@@ -783,14 +784,21 @@ VMAnonymousCache::Fault(struct VMAddressSpace* aspace, off_t offset)
|
||||
}
|
||||
|
||||
if (fPrecommittedPages == 0) {
|
||||
// never commit more than needed
|
||||
if (committed_size / B_PAGE_SIZE > page_count)
|
||||
return B_BAD_HANDLER;
|
||||
|
||||
// try to commit additional swap space/memory
|
||||
if (swap_space_reserve(B_PAGE_SIZE) == B_PAGE_SIZE) {
|
||||
fCommittedSwapSize += B_PAGE_SIZE;
|
||||
} else {
|
||||
int priority = aspace == VMAddressSpace::Kernel()
|
||||
? VM_PRIORITY_SYSTEM : VM_PRIORITY_USER;
|
||||
if (vm_try_reserve_memory(B_PAGE_SIZE, priority, 0) != B_OK)
|
||||
if (vm_try_reserve_memory(B_PAGE_SIZE, priority, 0) != B_OK) {
|
||||
dprintf("%p->VMAnonymousCache::Fault(): Failed to reserve "
|
||||
"%d bytes of RAM.\n", this, (int)B_PAGE_SIZE);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
|
||||
committed_size += B_PAGE_SIZE;
|
||||
|
||||
@@ -60,8 +60,9 @@ VMAnonymousNoSwapCache::Init(bool canOvercommit, int32 numPrecommittedPages,
|
||||
status_t
|
||||
VMAnonymousNoSwapCache::Commit(off_t size, int priority)
|
||||
{
|
||||
// if we can overcommit, we don't commit here, but in anonymous_fault()
|
||||
if (fCanOvercommit) {
|
||||
// If we can overcommit, we don't commit here, but in Fault(). We always
|
||||
// unreserve memory, if we're asked to shrink our commitment, though.
|
||||
if (fCanOvercommit && size > committed_size) {
|
||||
if (fHasPrecommitted)
|
||||
return B_OK;
|
||||
|
||||
@@ -138,11 +139,18 @@ VMAnonymousNoSwapCache::Fault(struct VMAddressSpace *aspace, off_t offset)
|
||||
}
|
||||
|
||||
if (fPrecommittedPages == 0) {
|
||||
// never commit more than needed
|
||||
if (committed_size / B_PAGE_SIZE > page_count)
|
||||
return B_BAD_HANDLER;
|
||||
|
||||
// try to commit additional memory
|
||||
int priority = aspace == VMAddressSpace::Kernel()
|
||||
? VM_PRIORITY_SYSTEM : VM_PRIORITY_USER;
|
||||
if (vm_try_reserve_memory(B_PAGE_SIZE, priority, 0) != B_OK)
|
||||
if (vm_try_reserve_memory(B_PAGE_SIZE, priority, 0) != B_OK) {
|
||||
dprintf("%p->VMAnonymousNoSwapCache::Fault(): Failed to "
|
||||
"reserve %d bytes of RAM.\n", this, (int)B_PAGE_SIZE);
|
||||
return B_NO_MEMORY;
|
||||
}
|
||||
|
||||
committed_size += B_PAGE_SIZE;
|
||||
} else
|
||||
|
||||
Reference in New Issue
Block a user