mirror of
https://github.com/RGBCube/serenity
synced 2025-07-19 07:07:39 +00:00
Kernel: Remove 1 level of indirection for AnonymousVMObject CoW bitmaps
Instead of keeping AnonymousVMObject::m_cow_map in an OwnPtr<Bitmap>, just make the Bitmap a regular value member. This increases the size of the VMObject by 8 bytes, but removes some of the kmalloc/kfree spam incurred by sys$fork().
This commit is contained in:
parent
ddaeb294dc
commit
4515652001
2 changed files with 12 additions and 12 deletions
|
@ -336,7 +336,7 @@ size_t AnonymousVMObject::count_needed_commit_pages_for_nonvolatile_range(const
|
||||||
auto range_end = range.base + range.count;
|
auto range_end = range.base + range.count;
|
||||||
for (size_t page_index = range.base; page_index < range_end; page_index++) {
|
for (size_t page_index = range.base; page_index < range_end; page_index++) {
|
||||||
// COW pages are accounted for in m_shared_committed_cow_pages
|
// COW pages are accounted for in m_shared_committed_cow_pages
|
||||||
if (m_cow_map && m_cow_map->get(page_index))
|
if (!m_cow_map.is_null() && m_cow_map.get(page_index))
|
||||||
continue;
|
continue;
|
||||||
auto& phys_page = m_physical_pages[page_index];
|
auto& phys_page = m_physical_pages[page_index];
|
||||||
if (phys_page && phys_page->is_shared_zero_page())
|
if (phys_page && phys_page->is_shared_zero_page())
|
||||||
|
@ -355,7 +355,7 @@ size_t AnonymousVMObject::mark_committed_pages_for_nonvolatile_range(const Volat
|
||||||
auto range_end = range.base + range.count;
|
auto range_end = range.base + range.count;
|
||||||
for (size_t page_index = range.base; page_index < range_end; page_index++) {
|
for (size_t page_index = range.base; page_index < range_end; page_index++) {
|
||||||
// COW pages are accounted for in m_shared_committed_cow_pages
|
// COW pages are accounted for in m_shared_committed_cow_pages
|
||||||
if (m_cow_map && m_cow_map->get(page_index))
|
if (!m_cow_map.is_null() && m_cow_map.get(page_index))
|
||||||
continue;
|
continue;
|
||||||
auto& phys_page = m_physical_pages[page_index];
|
auto& phys_page = m_physical_pages[page_index];
|
||||||
if (phys_page && phys_page->is_shared_zero_page()) {
|
if (phys_page && phys_page->is_shared_zero_page()) {
|
||||||
|
@ -395,17 +395,17 @@ RefPtr<PhysicalPage> AnonymousVMObject::allocate_committed_page(size_t page_inde
|
||||||
|
|
||||||
Bitmap& AnonymousVMObject::ensure_cow_map()
|
Bitmap& AnonymousVMObject::ensure_cow_map()
|
||||||
{
|
{
|
||||||
if (!m_cow_map)
|
if (m_cow_map.is_null())
|
||||||
m_cow_map = make<Bitmap>(page_count(), true);
|
m_cow_map = Bitmap { page_count(), true };
|
||||||
return *m_cow_map;
|
return m_cow_map;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonymousVMObject::ensure_or_reset_cow_map()
|
void AnonymousVMObject::ensure_or_reset_cow_map()
|
||||||
{
|
{
|
||||||
if (!m_cow_map)
|
if (m_cow_map.is_null())
|
||||||
m_cow_map = make<Bitmap>(page_count(), true);
|
ensure_cow_map();
|
||||||
else
|
else
|
||||||
m_cow_map->fill(true);
|
m_cow_map.fill(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnonymousVMObject::should_cow(size_t page_index, bool is_shared) const
|
bool AnonymousVMObject::should_cow(size_t page_index, bool is_shared) const
|
||||||
|
@ -415,7 +415,7 @@ bool AnonymousVMObject::should_cow(size_t page_index, bool is_shared) const
|
||||||
return true;
|
return true;
|
||||||
if (is_shared)
|
if (is_shared)
|
||||||
return false;
|
return false;
|
||||||
return m_cow_map && m_cow_map->get(page_index);
|
return !m_cow_map.is_null() && m_cow_map.get(page_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonymousVMObject::set_should_cow(size_t page_index, bool cow)
|
void AnonymousVMObject::set_should_cow(size_t page_index, bool cow)
|
||||||
|
@ -425,9 +425,9 @@ void AnonymousVMObject::set_should_cow(size_t page_index, bool cow)
|
||||||
|
|
||||||
size_t AnonymousVMObject::cow_pages() const
|
size_t AnonymousVMObject::cow_pages() const
|
||||||
{
|
{
|
||||||
if (!m_cow_map)
|
if (m_cow_map.is_null())
|
||||||
return 0;
|
return 0;
|
||||||
return m_cow_map->count_slow(true);
|
return m_cow_map.count_slow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AnonymousVMObject::is_nonvolatile(size_t page_index)
|
bool AnonymousVMObject::is_nonvolatile(size_t page_index)
|
||||||
|
|
|
@ -147,7 +147,7 @@ private:
|
||||||
Vector<PurgeablePageRanges*> m_purgeable_ranges;
|
Vector<PurgeablePageRanges*> m_purgeable_ranges;
|
||||||
size_t m_unused_committed_pages { 0 };
|
size_t m_unused_committed_pages { 0 };
|
||||||
|
|
||||||
mutable OwnPtr<Bitmap> m_cow_map;
|
Bitmap m_cow_map;
|
||||||
|
|
||||||
// We share a pool of committed cow-pages with clones
|
// We share a pool of committed cow-pages with clones
|
||||||
RefPtr<CommittedCowPages> m_shared_committed_cow_pages;
|
RefPtr<CommittedCowPages> m_shared_committed_cow_pages;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue