mirror of
https://github.com/RGBCube/serenity
synced 2025-07-23 19:37:34 +00:00
Kernel: Add a specific-page variant of Region::commit()
This commit is contained in:
parent
c0e81b26b6
commit
1d4d6f16b2
2 changed files with 26 additions and 13 deletions
|
@ -90,25 +90,37 @@ NonnullOwnPtr<Region> Region::clone()
|
||||||
return clone_region;
|
return clone_region;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Region::commit()
|
bool Region::commit()
|
||||||
{
|
{
|
||||||
InterruptDisabler disabler;
|
InterruptDisabler disabler;
|
||||||
#ifdef MM_DEBUG
|
#ifdef MM_DEBUG
|
||||||
dbgprintf("MM: commit %u pages in Region %p (VMO=%p) at V%p\n", vmobject().page_count(), this, &vmobject(), vaddr().get());
|
dbgprintf("MM: commit %u pages in Region %p (VMO=%p) at V%p\n", vmobject().page_count(), this, &vmobject(), vaddr().get());
|
||||||
#endif
|
#endif
|
||||||
for (size_t i = 0; i < page_count(); ++i) {
|
for (size_t i = 0; i < page_count(); ++i) {
|
||||||
auto& vmobject_physical_page_entry = vmobject().physical_pages()[first_page_index() + i];
|
if (!commit(i))
|
||||||
if (!vmobject_physical_page_entry.is_null())
|
return false;
|
||||||
continue;
|
|
||||||
auto physical_page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
|
|
||||||
if (!physical_page) {
|
|
||||||
kprintf("MM: commit was unable to allocate a physical page\n");
|
|
||||||
return -ENOMEM;
|
|
||||||
}
|
|
||||||
vmobject_physical_page_entry = move(physical_page);
|
|
||||||
remap_page(i);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Region::commit(size_t page_index)
|
||||||
|
{
|
||||||
|
ASSERT(vmobject().is_anonymous() || vmobject().is_purgeable());
|
||||||
|
InterruptDisabler disabler;
|
||||||
|
#ifdef MM_DEBUG
|
||||||
|
dbgprintf("MM: commit single page (%zu) in Region %p (VMO=%p) at V%p\n", page_index, vmobject().page_count(), this, &vmobject(), vaddr().get());
|
||||||
|
#endif
|
||||||
|
auto& vmobject_physical_page_entry = vmobject().physical_pages()[first_page_index() + page_index];
|
||||||
|
if (!vmobject_physical_page_entry.is_null())
|
||||||
|
return true;
|
||||||
|
auto physical_page = MM.allocate_user_physical_page(MemoryManager::ShouldZeroFill::Yes);
|
||||||
|
if (!physical_page) {
|
||||||
|
kprintf("MM: commit was unable to allocate a physical page\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
vmobject_physical_page_entry = move(physical_page);
|
||||||
|
remap_page(page_index);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 Region::cow_pages() const
|
u32 Region::cow_pages() const
|
||||||
|
|
|
@ -98,7 +98,8 @@ public:
|
||||||
return m_offset_in_vmo;
|
return m_offset_in_vmo;
|
||||||
}
|
}
|
||||||
|
|
||||||
int commit();
|
bool commit();
|
||||||
|
bool commit(size_t page_index);
|
||||||
|
|
||||||
size_t amount_resident() const;
|
size_t amount_resident() const;
|
||||||
size_t amount_shared() const;
|
size_t amount_shared() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue