diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp index 0009cceac2f..4ea8b9bd392 100644 --- a/Kernel/VM/MemoryManager.cpp +++ b/Kernel/VM/MemoryManager.cpp @@ -842,13 +842,13 @@ bool MemoryManager::validate_user_stack(const Process& process, VirtualAddress v void MemoryManager::register_vmobject(VMObject& vmobject) { ScopedSpinLock lock(s_mm_lock); - m_vmobjects.append(&vmobject); + m_vmobjects.append(vmobject); } void MemoryManager::unregister_vmobject(VMObject& vmobject) { ScopedSpinLock lock(s_mm_lock); - m_vmobjects.remove(&vmobject); + m_vmobjects.remove(vmobject); } void MemoryManager::register_region(Region& region) diff --git a/Kernel/VM/MemoryManager.h b/Kernel/VM/MemoryManager.h index 5f68538e1ae..90607958a1f 100644 --- a/Kernel/VM/MemoryManager.h +++ b/Kernel/VM/MemoryManager.h @@ -239,7 +239,7 @@ private: Vector m_physical_memory_ranges; Vector m_reserved_memory_ranges; - InlineLinkedList m_vmobjects; + VMObject::List m_vmobjects; }; template diff --git a/Kernel/VM/VMObject.h b/Kernel/VM/VMObject.h index b58e5683872..493708aaef0 100644 --- a/Kernel/VM/VMObject.h +++ b/Kernel/VM/VMObject.h @@ -7,7 +7,7 @@ #pragma once #include -#include +#include #include #include #include @@ -26,8 +26,7 @@ public: }; class VMObject : public RefCounted - , public Weakable - , public InlineLinkedListNode { + , public Weakable { friend class MemoryManager; friend class Region; @@ -50,10 +49,6 @@ public: virtual const char* class_name() const = 0; - // For InlineLinkedListNode - VMObject* m_next { nullptr }; - VMObject* m_prev { nullptr }; - ALWAYS_INLINE void ref_region() { m_regions_count++; } ALWAYS_INLINE void unref_region() { m_regions_count--; } ALWAYS_INLINE bool is_shared_by_multiple_regions() const { return m_regions_count > 1; } @@ -75,6 +70,7 @@ protected: template void for_each_region(Callback); + IntrusiveListNode m_list_node; Vector> m_physical_pages; Lock m_paging_lock { "VMObject" }; @@ -88,6 +84,9 @@ private: Atomic m_regions_count { 0 }; HashTable m_on_deleted; SpinLock m_on_deleted_lock; + +public: + using List = IntrusiveList, &VMObject::m_list_node>; }; }