summaryrefslogtreecommitdiff
path: root/Kernel/VM/AnonymousVMObject.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-03-04 10:05:38 +0100
committerAndreas Kling <kling@serenityos.org>2021-03-04 10:11:37 +0100
commit4515652001b715a0da7908d815ceb5c00e8c79b9 (patch)
tree845535a7369a0d21067b80632064ac2fd77ca12b /Kernel/VM/AnonymousVMObject.cpp
parentddaeb294dc8d76f3636cd1dcab88a67d6b3e0610 (diff)
downloadserenity-4515652001b715a0da7908d815ceb5c00e8c79b9.zip
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().
Diffstat (limited to 'Kernel/VM/AnonymousVMObject.cpp')
-rw-r--r--Kernel/VM/AnonymousVMObject.cpp22
1 files changed, 11 insertions, 11 deletions
diff --git a/Kernel/VM/AnonymousVMObject.cpp b/Kernel/VM/AnonymousVMObject.cpp
index 7a8f1f3513..06a3581378 100644
--- a/Kernel/VM/AnonymousVMObject.cpp
+++ b/Kernel/VM/AnonymousVMObject.cpp
@@ -336,7 +336,7 @@ size_t AnonymousVMObject::count_needed_commit_pages_for_nonvolatile_range(const
auto range_end = range.base + range.count;
for (size_t page_index = range.base; page_index < range_end; page_index++) {
// 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;
auto& phys_page = m_physical_pages[page_index];
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;
for (size_t page_index = range.base; page_index < range_end; page_index++) {
// 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;
auto& phys_page = m_physical_pages[page_index];
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()
{
- if (!m_cow_map)
- m_cow_map = make<Bitmap>(page_count(), true);
- return *m_cow_map;
+ if (m_cow_map.is_null())
+ m_cow_map = Bitmap { page_count(), true };
+ return m_cow_map;
}
void AnonymousVMObject::ensure_or_reset_cow_map()
{
- if (!m_cow_map)
- m_cow_map = make<Bitmap>(page_count(), true);
+ if (m_cow_map.is_null())
+ ensure_cow_map();
else
- m_cow_map->fill(true);
+ m_cow_map.fill(true);
}
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;
if (is_shared)
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)
@@ -425,9 +425,9 @@ void AnonymousVMObject::set_should_cow(size_t page_index, bool cow)
size_t AnonymousVMObject::cow_pages() const
{
- if (!m_cow_map)
+ if (m_cow_map.is_null())
return 0;
- return m_cow_map->count_slow(true);
+ return m_cow_map.count_slow(true);
}
bool AnonymousVMObject::is_nonvolatile(size_t page_index)