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
Notes: sideshowbarker 2024-07-19 06:49:56 +09:00

View File

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