1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 04:48:14 +00:00

Kernel: Add for_each_vmobject_of_type<T>

This makes iterating over a specific type of VMObjects a bit nicer.
This commit is contained in:
Andreas Kling 2020-05-08 22:10:47 +02:00
parent 239fd33405
commit 55f61c0004
8 changed files with 57 additions and 16 deletions

View file

@ -441,16 +441,13 @@ RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill s
klog() << "MM: no user physical regions available (?)";
}
for_each_vmobject([&](auto& vmobject) {
if (vmobject.is_purgeable()) {
auto& purgeable_vmobject = static_cast<PurgeableVMObject&>(vmobject);
int purged_page_count = purgeable_vmobject.purge_with_interrupts_disabled({});
if (purged_page_count) {
klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &purgeable_vmobject << "}";
page = find_free_user_physical_page();
ASSERT(page);
return IterationDecision::Break;
}
for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
int purged_page_count = vmobject.purge_with_interrupts_disabled({});
if (purged_page_count) {
klog() << "MM: Purge saved the day! Purged " << purged_page_count << " pages from PurgeableVMObject{" << &vmobject << "}";
page = find_free_user_physical_page();
ASSERT(page);
return IterationDecision::Break;
}
return IterationDecision::Continue;
});