mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
Kernel: Switch VMObject to IntrusiveList from InlineLinkedList
This commit is contained in:
parent
e6f73d69a2
commit
2045782a6e
Notes:
sideshowbarker
2024-07-18 17:21:31 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/2045782a6ec Pull-request: https://github.com/SerenityOS/serenity/pull/7479
@ -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)
|
||||
|
@ -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>
|
||||
|
@ -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>;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user