mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 00:08:11 +00:00
Kernel: Switch VMObject to IntrusiveList from InlineLinkedList
This commit is contained in:
parent
e6f73d69a2
commit
2045782a6e
3 changed files with 9 additions and 10 deletions
|
@ -842,13 +842,13 @@ bool MemoryManager::validate_user_stack(const Process& process, VirtualAddress v
|
||||||
void MemoryManager::register_vmobject(VMObject& vmobject)
|
void MemoryManager::register_vmobject(VMObject& vmobject)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
m_vmobjects.append(&vmobject);
|
m_vmobjects.append(vmobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryManager::unregister_vmobject(VMObject& vmobject)
|
void MemoryManager::unregister_vmobject(VMObject& vmobject)
|
||||||
{
|
{
|
||||||
ScopedSpinLock lock(s_mm_lock);
|
ScopedSpinLock lock(s_mm_lock);
|
||||||
m_vmobjects.remove(&vmobject);
|
m_vmobjects.remove(vmobject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MemoryManager::register_region(Region& region)
|
void MemoryManager::register_region(Region& region)
|
||||||
|
|
|
@ -239,7 +239,7 @@ private:
|
||||||
Vector<PhysicalMemoryRange> m_physical_memory_ranges;
|
Vector<PhysicalMemoryRange> m_physical_memory_ranges;
|
||||||
Vector<ContiguousReservedMemoryRange> m_reserved_memory_ranges;
|
Vector<ContiguousReservedMemoryRange> m_reserved_memory_ranges;
|
||||||
|
|
||||||
InlineLinkedList<VMObject> m_vmobjects;
|
VMObject::List m_vmobjects;
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/HashTable.h>
|
#include <AK/HashTable.h>
|
||||||
#include <AK/InlineLinkedList.h>
|
#include <AK/IntrusiveList.h>
|
||||||
#include <AK/RefCounted.h>
|
#include <AK/RefCounted.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/Vector.h>
|
#include <AK/Vector.h>
|
||||||
|
@ -26,8 +26,7 @@ public:
|
||||||
};
|
};
|
||||||
|
|
||||||
class VMObject : public RefCounted<VMObject>
|
class VMObject : public RefCounted<VMObject>
|
||||||
, public Weakable<VMObject>
|
, public Weakable<VMObject> {
|
||||||
, public InlineLinkedListNode<VMObject> {
|
|
||||||
friend class MemoryManager;
|
friend class MemoryManager;
|
||||||
friend class Region;
|
friend class Region;
|
||||||
|
|
||||||
|
@ -50,10 +49,6 @@ public:
|
||||||
|
|
||||||
virtual const char* class_name() const = 0;
|
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 ref_region() { m_regions_count++; }
|
||||||
ALWAYS_INLINE void unref_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; }
|
ALWAYS_INLINE bool is_shared_by_multiple_regions() const { return m_regions_count > 1; }
|
||||||
|
@ -75,6 +70,7 @@ protected:
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
void for_each_region(Callback);
|
void for_each_region(Callback);
|
||||||
|
|
||||||
|
IntrusiveListNode<VMObject> m_list_node;
|
||||||
Vector<RefPtr<PhysicalPage>> m_physical_pages;
|
Vector<RefPtr<PhysicalPage>> m_physical_pages;
|
||||||
Lock m_paging_lock { "VMObject" };
|
Lock m_paging_lock { "VMObject" };
|
||||||
|
|
||||||
|
@ -88,6 +84,9 @@ private:
|
||||||
Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_regions_count { 0 };
|
Atomic<u32, AK::MemoryOrder::memory_order_relaxed> m_regions_count { 0 };
|
||||||
HashTable<VMObjectDeletedHandler*> m_on_deleted;
|
HashTable<VMObjectDeletedHandler*> m_on_deleted;
|
||||||
SpinLock<u8> m_on_deleted_lock;
|
SpinLock<u8> m_on_deleted_lock;
|
||||||
|
|
||||||
|
public:
|
||||||
|
using List = IntrusiveList<VMObject, RawPtr<VMObject>, &VMObject::m_list_node>;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue