mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 01:20:25 +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:
parent
072dde9387
commit
09d0fae2c6
Notes:
sideshowbarker
2024-07-17 08:13:21 +09:00
Author: https://github.com/dylanbobb Commit: https://github.com/SerenityOS/serenity/commit/09d0fae2c6 Pull-request: https://github.com/SerenityOS/serenity/pull/14867 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/circl-lastname
2 changed files with 20 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -23,6 +23,7 @@ public:
|
|||
size_t amount_clean() const;
|
||||
|
||||
int release_all_clean_pages();
|
||||
int try_release_clean_pages(int page_amount);
|
||||
|
||||
u32 writable_mappings() const;
|
||||
u32 executable_mappings() const;
|
||||
|
|
Loading…
Reference in a new issue