From 0a4a06eee3851615a7379ebe48e4baecda96187d Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Wed, 2 Oct 2024 15:47:11 -0400 Subject: [PATCH] kernel/vm: Change cache commitment at end of Resize(). If we change it at the top, then we shrink the commitment before we actually have released the relevant pages. --- src/system/kernel/vm/VMCache.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/system/kernel/vm/VMCache.cpp b/src/system/kernel/vm/VMCache.cpp index aa60746e4c..4cbc6a15e5 100644 --- a/src/system/kernel/vm/VMCache.cpp +++ b/src/system/kernel/vm/VMCache.cpp @@ -1157,13 +1157,9 @@ VMCache::Resize(off_t newSize, int priority) { TRACE(("VMCache::Resize(cache %p, newSize %" B_PRIdOFF ") old size %" B_PRIdOFF "\n", this, newSize, this->virtual_end)); - this->AssertLocked(); - T(Resize(this, newSize)); - status_t status = Commit(newSize - virtual_base, priority); - if (status != B_OK) - return status; + AssertLocked(); page_num_t oldPageCount = (page_num_t)((virtual_end + B_PAGE_SIZE - 1) >> PAGE_SHIFT); @@ -1177,6 +1173,10 @@ VMCache::Resize(off_t newSize, int priority) ; } + status_t status = Commit(newSize - virtual_base, priority); + if (status != B_OK) + return status; + virtual_end = newSize; return B_OK; }