summaryrefslogtreecommitdiff
path: root/Kernel/VM/VMObject.h
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-01-02 12:03:14 -0700
committerAndreas Kling <kling@serenityos.org>2021-01-02 20:56:35 +0100
commitc630669304b62f8cc8e28548ba9dfba29c82ca33 (patch)
treeae478f74f53183a940366f544076bbd3a8b119c3 /Kernel/VM/VMObject.h
parente3190bd144256b34c3044da26a5a5ce1c714f706 (diff)
downloadserenity-c630669304b62f8cc8e28548ba9dfba29c82ca33.zip
Kernel: If a VMObject is shared, broadcast page remappings
If we remap pages (e.g. lazy allocation) inside a VMObject that is shared among more than one region, broadcast it to any other region that may be mapping the same page.
Diffstat (limited to 'Kernel/VM/VMObject.h')
-rw-r--r--Kernel/VM/VMObject.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h
index d9f48bd4ca..2a48daa66a 100644
--- a/Kernel/VM/VMObject.h
+++ b/Kernel/VM/VMObject.h
@@ -67,6 +67,10 @@ public:
VMObject* m_next { nullptr };
VMObject* m_prev { nullptr };
+ ALWAYS_INLINE void ref_region() { m_regions_count.fetch_add(1, AK::MemoryOrder::memory_order_relaxed); }
+ ALWAYS_INLINE void unref_region() { m_regions_count.fetch_sub(1, AK::MemoryOrder::memory_order_relaxed); }
+ ALWAYS_INLINE bool is_shared_by_multiple_regions() const { return m_regions_count.load(AK::MemoryOrder::memory_order_relaxed) > 1; }
+
protected:
explicit VMObject(size_t);
explicit VMObject(const VMObject&);
@@ -83,6 +87,8 @@ private:
VMObject& operator=(const VMObject&) = delete;
VMObject& operator=(VMObject&&) = delete;
VMObject(VMObject&&) = delete;
+
+ Atomic<u32> m_regions_count { 0 };
};
}