Kernel: Release 1 page instead of all pages when starved for pages

Previously, when starved for pages, *all* clean file-backed memory
would be released, which is quite excessive.

This patch instead releases just 1 page, since only 1 page is needed
to satisfy the request to `allocate_physical_page()`
This commit is contained in:
dylanbobb 2022-08-14 23:08:22 -04:00 committed by Andreas Kling
parent 09d0fae2c6
commit 8180211431
Notes: sideshowbarker 2024-07-17 22:01:16 +09:00

View file

@ -949,8 +949,7 @@ ErrorOr<NonnullRefPtr<PhysicalPage>> MemoryManager::allocate_physical_page(Shoul
if (!vmobject.is_inode())
return IterationDecision::Continue;
auto& inode_vmobject = static_cast<InodeVMObject&>(vmobject);
// FIXME: It seems excessive to release *all* clean pages from the inode when we only need one.
if (auto released_page_count = inode_vmobject.release_all_clean_pages()) {
if (auto released_page_count = inode_vmobject.try_release_clean_pages(1)) {
dbgln("MM: Clean inode release saved the day! Released {} pages from InodeVMObject", released_page_count);
page = find_free_physical_page(false);
VERIFY(page);