mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 10:48:41 +00:00
Kernel: Allow release of a specific amount of of clean pages
Previously, we could only release *all* clean pages. This patch makes it possible to release a specific amount of clean pages. If the attempted number of pages to release is more than the amount of clean pages, all clean pages will be released.
This commit is contained in:
@@ -67,6 +67,25 @@ int InodeVMObject::release_all_clean_pages()
|
||||
return count;
|
||||
}
|
||||
|
||||
int InodeVMObject::try_release_clean_pages(int page_amount)
|
||||
{
|
||||
SpinlockLocker locker(m_lock);
|
||||
|
||||
int count = 0;
|
||||
for (size_t i = 0; i < page_count() && count < page_amount; ++i) {
|
||||
if (!m_dirty_pages.get(i) && m_physical_pages[i]) {
|
||||
m_physical_pages[i] = nullptr;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
if (count) {
|
||||
for_each_region([](auto& region) {
|
||||
region.remap();
|
||||
});
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
u32 InodeVMObject::writable_mappings() const
|
||||
{
|
||||
u32 count = 0;
|
||||
|
||||
Reference in New Issue
Block a user