mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 13:38:11 +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:
parent
ac78f1e812
commit
c2792212f4
9 changed files with 39 additions and 53 deletions
|
@ -10,15 +10,14 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
|
||||
NonnullRefPtr<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool may_return_to_freelist)
|
||||
{
|
||||
auto& physical_page_entry = MM.get_physical_page_entry(paddr);
|
||||
return adopt_ref(*new (&physical_page_entry.physical_page) PhysicalPage(supervisor, may_return_to_freelist));
|
||||
return adopt_ref(*new (&physical_page_entry.physical_page) PhysicalPage(may_return_to_freelist));
|
||||
}
|
||||
|
||||
PhysicalPage::PhysicalPage(bool supervisor, bool may_return_to_freelist)
|
||||
PhysicalPage::PhysicalPage(bool may_return_to_freelist)
|
||||
: m_may_return_to_freelist(may_return_to_freelist)
|
||||
, m_supervisor(supervisor)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -31,14 +30,8 @@ void PhysicalPage::free_this()
|
|||
{
|
||||
if (m_may_return_to_freelist) {
|
||||
auto paddr = MM.get_physical_address(*this);
|
||||
bool is_supervisor = m_supervisor;
|
||||
|
||||
this->~PhysicalPage(); // delete in place
|
||||
|
||||
if (is_supervisor)
|
||||
MM.deallocate_supervisor_physical_page(paddr);
|
||||
else
|
||||
MM.deallocate_user_physical_page(paddr);
|
||||
MM.deallocate_physical_page(paddr);
|
||||
} else {
|
||||
this->~PhysicalPage(); // delete in place
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue