1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 21:27:44 +00:00

Kernel: Assert on startup if we don't find any physical pages

Instead of checking this on every page allocation, just check it once
on startup. :^)
This commit is contained in:
Andreas Kling 2020-05-08 22:15:02 +02:00
parent 55f61c0004
commit 85a3678b4f

View file

@ -216,6 +216,9 @@ void MemoryManager::parse_memory_map()
for (auto& region : m_user_physical_regions) for (auto& region : m_user_physical_regions)
m_user_physical_pages += region.finalize_capacity(); m_user_physical_pages += region.finalize_capacity();
ASSERT(m_super_physical_pages > 0);
ASSERT(m_user_physical_pages > 0);
} }
const PageTableEntry* MemoryManager::pte(const PageDirectory& page_directory, VirtualAddress vaddr) const PageTableEntry* MemoryManager::pte(const PageDirectory& page_directory, VirtualAddress vaddr)
@ -434,13 +437,11 @@ RefPtr<PhysicalPage> MemoryManager::find_free_user_physical_page()
RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill) RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill)
{ {
InterruptDisabler disabler; InterruptDisabler disabler;
RefPtr<PhysicalPage> page = find_free_user_physical_page(); auto page = find_free_user_physical_page();
if (!page) { if (!page) {
if (m_user_physical_regions.is_empty()) { // We didn't have a single free physical page. Let's try to free something up!
klog() << "MM: no user physical regions available (?)"; // First, we look for a purgeable VMObject in the volatile state.
}
for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) { for_each_vmobject_of_type<PurgeableVMObject>([&](auto& vmobject) {
int purged_page_count = vmobject.purge_with_interrupts_disabled({}); int purged_page_count = vmobject.purge_with_interrupts_disabled({});
if (purged_page_count) { if (purged_page_count) {