mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +00:00
Kernel: Fix the search method of free userspace physical pages (#742)
Now the userspace page allocator will search through physical regions, and stop the search as it finds an available page. Also remove an "address of" sign since we don't need that when counting size of physical regions
This commit is contained in:
@@ -144,7 +144,7 @@ void MemoryManager::initialize_paging()
|
||||
} else {
|
||||
if (region.is_null() || region_is_super || region->upper().offset(PAGE_SIZE) != addr) {
|
||||
m_user_physical_regions.append(PhysicalRegion::create(addr, addr));
|
||||
region = &m_user_physical_regions.last();
|
||||
region = m_user_physical_regions.last();
|
||||
region_is_super = false;
|
||||
} else {
|
||||
region->expand(region->lower(), addr);
|
||||
@@ -386,16 +386,21 @@ void MemoryManager::deallocate_user_physical_page(PhysicalPage&& page)
|
||||
ASSERT_NOT_REACHED();
|
||||
}
|
||||
|
||||
RefPtr<PhysicalPage> MemoryManager::find_free_user_physical_page()
|
||||
{
|
||||
RefPtr<PhysicalPage> page;
|
||||
for (auto& region : m_user_physical_regions) {
|
||||
page = region.take_free_page(false);
|
||||
if (!page.is_null())
|
||||
break;
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
RefPtr<PhysicalPage> MemoryManager::allocate_user_physical_page(ShouldZeroFill should_zero_fill)
|
||||
{
|
||||
InterruptDisabler disabler;
|
||||
RefPtr<PhysicalPage> page;
|
||||
|
||||
for (auto& region : m_user_physical_regions) {
|
||||
page = region.take_free_page(false);
|
||||
if (page.is_null())
|
||||
continue;
|
||||
}
|
||||
RefPtr<PhysicalPage> page = find_free_user_physical_page();
|
||||
|
||||
if (!page) {
|
||||
if (m_user_physical_regions.is_empty()) {
|
||||
|
||||
Reference in New Issue
Block a user