فهرست منبع

Kernel: Switch VMObject to IntrusiveList from InlineLinkedList

Brian Gianforcaro 4 سال پیش
والد
کامیت
2045782a6e
3فایلهای تغییر یافته به همراه9 افزوده شده و 10 حذف شده
  1. 2 2
      Kernel/VM/MemoryManager.cpp
  2. 1 1
      Kernel/VM/MemoryManager.h
  3. 6 7
      Kernel/VM/VMObject.h

+ 2 - 2
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)

+ 1 - 1
Kernel/VM/MemoryManager.h

@@ -239,7 +239,7 @@ private:
     Vector<PhysicalMemoryRange> m_physical_memory_ranges;
     Vector<ContiguousReservedMemoryRange> m_reserved_memory_ranges;
 
-    InlineLinkedList<VMObject> m_vmobjects;
+    VMObject::List m_vmobjects;
 };
 
 template<typename Callback>

+ 6 - 7
Kernel/VM/VMObject.h

@@ -7,7 +7,7 @@
 #pragma once
 
 #include <AK/HashTable.h>
-#include <AK/InlineLinkedList.h>
+#include <AK/IntrusiveList.h>
 #include <AK/RefCounted.h>
 #include <AK/RefPtr.h>
 #include <AK/Vector.h>
@@ -26,8 +26,7 @@ public:
 };
 
 class VMObject : public RefCounted<VMObject>
-    , public Weakable<VMObject>
-    , public InlineLinkedListNode<VMObject> {
+    , public Weakable<VMObject> {
     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<typename Callback>
     void for_each_region(Callback);
 
+    IntrusiveListNode<VMObject> m_list_node;
     Vector<RefPtr<PhysicalPage>> m_physical_pages;
     Lock m_paging_lock { "VMObject" };
 
@@ -88,6 +84,9 @@ private:
     Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_regions_count { 0 };
     HashTable<VMObjectDeletedHandler*> m_on_deleted;
     SpinLock<u8> m_on_deleted_lock;
+
+public:
+    using List = IntrusiveList<VMObject, RawPtr<VMObject>, &VMObject::m_list_node>;
 };
 
 }