mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-13 14:42:51 +00:00
This significantly reduces the pressure on the kernel heap when allocating a lot of pages. Previously at about 250MB allocated, the free page list would outgrow the kernel's heap. Given that there is no longer a page list, this does not happen. The next barrier will be the kernel memory used by the page records for in-use memory. This kicks in at about 1GB.
42 lines
1.1 KiB
C++
42 lines
1.1 KiB
C++
#include <Kernel/VM/MemoryManager.h>
|
|
#include <Kernel/VM/PhysicalPage.h>
|
|
#include <Kernel/kmalloc.h>
|
|
|
|
Retained<PhysicalPage> PhysicalPage::create_eternal(PhysicalAddress paddr, bool supervisor)
|
|
{
|
|
void* slot = kmalloc_eternal(sizeof(PhysicalPage));
|
|
new (slot) PhysicalPage(paddr, supervisor);
|
|
return adopt(*(PhysicalPage*)slot);
|
|
}
|
|
|
|
Retained<PhysicalPage> PhysicalPage::create(PhysicalAddress paddr, bool supervisor)
|
|
{
|
|
void* slot = kmalloc(sizeof(PhysicalPage));
|
|
new (slot) PhysicalPage(paddr, supervisor, false);
|
|
return adopt(*(PhysicalPage*)slot);
|
|
}
|
|
|
|
PhysicalPage::PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist)
|
|
: m_may_return_to_freelist(may_return_to_freelist)
|
|
, m_supervisor(supervisor)
|
|
, m_paddr(paddr)
|
|
{
|
|
}
|
|
|
|
void PhysicalPage::return_to_freelist()
|
|
{
|
|
ASSERT((paddr().get() & ~PAGE_MASK) == 0);
|
|
|
|
InterruptDisabler disabler;
|
|
|
|
m_retain_count = 1;
|
|
|
|
if (m_supervisor)
|
|
MM.deallocate_supervisor_physical_page(*this);
|
|
else
|
|
MM.deallocate_user_physical_page(*this);
|
|
|
|
#ifdef MM_DEBUG
|
|
dbgprintf("MM: P%x released to freelist\n", m_paddr.get());
|
|
#endif
|
|
}
|