kernel/vm: Accept negative (no) priority in VMCache's Resize and Rebase.
This means that we won't try and change the commitment at all, and it will be up to the caller to do that instead. Also move the commitment change from the beginning to the end of Rebase, matching Resize. This way, we won't trip the new asserts added to Commit() in the previous commits. Add a relevant assert to vm_try_reserve_memory to make sure the negative priority doesn't end up down that far.
This commit is contained in:
@@ -1172,15 +1172,16 @@ VMCache::Resize(off_t newSize, int priority)
|
||||
>> PAGE_SHIFT);
|
||||
|
||||
if (newPageCount < oldPageCount) {
|
||||
// we need to remove all pages in the cache outside of the new virtual
|
||||
// size
|
||||
// Remove all pages in the cache outside of the new virtual size.
|
||||
while (_FreePageRange(pages.GetIterator(newPageCount, true, true)))
|
||||
;
|
||||
}
|
||||
|
||||
status_t status = Commit(newSize - virtual_base, priority);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
if (priority >= 0) {
|
||||
status_t status = Commit(newSize - virtual_base, priority);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
}
|
||||
|
||||
virtual_end = newSize;
|
||||
return B_OK;
|
||||
@@ -1200,23 +1201,24 @@ VMCache::Rebase(off_t newBase, int priority)
|
||||
{
|
||||
TRACE(("VMCache::Rebase(cache %p, newBase %lld) old base %lld\n",
|
||||
this, newBase, this->virtual_base));
|
||||
this->AssertLocked();
|
||||
|
||||
T(Rebase(this, newBase));
|
||||
|
||||
status_t status = Commit(virtual_end - newBase, priority);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
AssertLocked();
|
||||
|
||||
page_num_t basePage = (page_num_t)(newBase >> PAGE_SHIFT);
|
||||
|
||||
if (newBase > virtual_base) {
|
||||
// we need to remove all pages in the cache outside of the new virtual
|
||||
// base
|
||||
// Remove all pages in the cache outside of the new virtual base.
|
||||
while (_FreePageRange(pages.GetIterator(), &basePage))
|
||||
;
|
||||
}
|
||||
|
||||
if (priority >= 0) {
|
||||
status_t status = Commit(virtual_end - newBase, priority);
|
||||
if (status != B_OK)
|
||||
return status;
|
||||
}
|
||||
|
||||
virtual_base = newBase;
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
@@ -4710,6 +4710,7 @@ vm_unreserve_memory(size_t amount)
|
||||
status_t
|
||||
vm_try_reserve_memory(size_t amount, int priority, bigtime_t timeout)
|
||||
{
|
||||
ASSERT(priority >= 0 && priority < (int)B_COUNT_OF(kMemoryReserveForPriority));
|
||||
size_t reserve = kMemoryReserveForPriority[priority];
|
||||
|
||||
MutexLocker locker(sAvailableMemoryLock);
|
||||
|
||||
Reference in New Issue
Block a user