1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

Kernel: Remove "supervisor" bit from PhysicalPage

Instead of each PhysicalPage knowing whether it comes from the
supervisor pages or from the user pages, we can just check in both
sets when freeing a page.

It's just a handful of pointer range checks, nothing expensive.
This commit is contained in:
Andreas Kling 2021-07-11 23:12:32 +02:00
parent ac78f1e812
commit c2792212f4
9 changed files with 39 additions and 53 deletions

View file

@ -55,7 +55,7 @@ PhysicalRegion PhysicalRegion::take_pages_from_beginning(unsigned page_count)
return taken_region;
}
NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(size_t count, bool supervisor, size_t physical_alignment)
NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(size_t count, size_t physical_alignment)
{
VERIFY(m_pages);
VERIFY(m_used != m_pages);
@ -66,7 +66,7 @@ NonnullRefPtrVector<PhysicalPage> PhysicalRegion::take_contiguous_free_pages(siz
auto first_contiguous_page = find_contiguous_free_pages(count, physical_alignment);
for (size_t index = 0; index < count; index++)
physical_pages.append(PhysicalPage::create(m_lower.offset(PAGE_SIZE * (index + first_contiguous_page)), supervisor));
physical_pages.append(PhysicalPage::create(m_lower.offset(PAGE_SIZE * (index + first_contiguous_page))));
return physical_pages;
}
@ -134,7 +134,7 @@ Optional<unsigned> PhysicalRegion::find_and_allocate_contiguous_range(size_t cou
return {};
}
RefPtr<PhysicalPage> PhysicalRegion::take_free_page(bool supervisor)
RefPtr<PhysicalPage> PhysicalRegion::take_free_page()
{
VERIFY(m_pages);
@ -142,7 +142,7 @@ RefPtr<PhysicalPage> PhysicalRegion::take_free_page(bool supervisor)
if (!free_index.has_value())
return nullptr;
return PhysicalPage::create(m_lower.offset((PhysicalPtr)free_index.value() * PAGE_SIZE), supervisor);
return PhysicalPage::create(m_lower.offset((PhysicalPtr)free_index.value() * PAGE_SIZE));
}
void PhysicalRegion::free_page_at(PhysicalAddress addr)