diff options
author | Tom <tomut@yahoo.com> | 2021-01-02 12:03:14 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-01-02 20:56:35 +0100 |
commit | c630669304b62f8cc8e28548ba9dfba29c82ca33 (patch) | |
tree | ae478f74f53183a940366f544076bbd3a8b119c3 /Kernel/VM/VMObject.h | |
parent | e3190bd144256b34c3044da26a5a5ce1c714f706 (diff) | |
download | serenity-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.h | 6 |
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 }; }; } |