mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 04:07:44 +00:00
Kernel: Port VMObject to ListedRefCounted
The VMObject class now manages its own instance list (it was previously a member of MemoryManager.) Removal from the list is done safely on the last unref(), closing a race window in the previous implementation. Note that VMObject::all_instances() now has its own lock instead of using the global MM lock.
This commit is contained in:
parent
3a2d888913
commit
7979b5a8bb
4 changed files with 26 additions and 28 deletions
|
@ -204,18 +204,22 @@ public:
|
|||
template<IteratorFunction<VMObject&> Callback>
|
||||
static void for_each_vmobject(Callback callback)
|
||||
{
|
||||
ScopedSpinLock locker(s_mm_lock);
|
||||
for (auto& vmobject : MM.m_vmobjects) {
|
||||
if (callback(vmobject) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
VMObject::all_instances().with([&](auto& list) {
|
||||
for (auto& vmobject : list) {
|
||||
if (callback(vmobject) == IterationDecision::Break)
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
template<VoidFunction<VMObject&> Callback>
|
||||
static void for_each_vmobject(Callback callback)
|
||||
{
|
||||
for (auto& vmobject : MM.m_vmobjects)
|
||||
callback(vmobject);
|
||||
VMObject::all_instances().with([&](auto& list) {
|
||||
for (auto& vmobject : list) {
|
||||
callback(vmobject);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static Region* find_user_region_from_vaddr(AddressSpace&, VirtualAddress);
|
||||
|
@ -242,8 +246,6 @@ private:
|
|||
void initialize_physical_pages();
|
||||
void register_reserved_ranges();
|
||||
|
||||
void register_vmobject(VMObject&);
|
||||
void unregister_vmobject(VMObject&);
|
||||
void register_region(Region&);
|
||||
void unregister_region(Region&);
|
||||
|
||||
|
@ -289,8 +291,6 @@ private:
|
|||
Vector<UsedMemoryRange> m_used_memory_ranges;
|
||||
Vector<PhysicalMemoryRange> m_physical_memory_ranges;
|
||||
Vector<ContiguousReservedMemoryRange> m_reserved_memory_ranges;
|
||||
|
||||
VMObject::List m_vmobjects;
|
||||
};
|
||||
|
||||
inline bool is_user_address(VirtualAddress vaddr)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue