1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 17:45:08 +00:00

Kernel: Remove unnecessary counting of VMObject-attached Regions

VMObject already has an IntrusiveList of all the Regions that map it.
We were keeping a counter in addition to this, and only using it in
a single place to avoid iterating over the list in case it only had
1 entry.

Simplify VMObject by removing this counter and always iterating the
list even if there's only 1 entry. :^)
This commit is contained in:
Andreas Kling 2021-07-25 17:11:50 +02:00
parent ae3778c303
commit 0d963fd641
3 changed files with 5 additions and 16 deletions

View file

@ -225,18 +225,12 @@ bool Region::do_remap_vmobject_page(size_t page_index, bool with_flush)
bool Region::remap_vmobject_page(size_t page_index, bool with_flush)
{
bool success = true;
auto& vmobject = this->vmobject();
ScopedSpinLock lock(vmobject.m_lock);
if (vmobject.is_shared_by_multiple_regions()) {
vmobject.for_each_region([&](auto& region) {
if (!region.do_remap_vmobject_page(page_index, with_flush))
success = false;
});
} else {
if (!do_remap_vmobject_page(page_index, with_flush))
bool success = true;
vmobject.for_each_region([&](auto& region) {
if (!region.do_remap_vmobject_page(page_index, with_flush))
success = false;
}
});
return success;
}