1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-10 06:27:35 +00:00

Kernel: When physical page allocation fails, try to purge something

Instead of panicking right away when we run out of physical pages,
we now try to find a PurgeableVMObject with some volatile pages in it.
If we find one, we purge that entire object and steal one of its pages.

This makes it possible for the kernel to keep going instead of dying.
Very cool. :^)
This commit is contained in:
Andreas Kling 2019-12-26 11:45:36 +01:00
parent dafd715743
commit c1f8291ce4
3 changed files with 36 additions and 3 deletions

View file

@ -29,6 +29,19 @@ NonnullRefPtr<VMObject> PurgeableVMObject::clone()
int PurgeableVMObject::purge()
{
LOCKER(m_paging_lock);
return purge_impl();
}
int PurgeableVMObject::purge_with_interrupts_disabled(Badge<MemoryManager>)
{
ASSERT_INTERRUPTS_DISABLED();
if (m_paging_lock.is_locked())
return 0;
return purge_impl();
}
int PurgeableVMObject::purge_impl()
{
if (!m_volatile)
return 0;
int purged_page_count = 0;