ladybird/Kernel/VM/InodeVMObject.h
Andreas Kling 082ed6f417 Kernel: Simplify VMObject locking & page fault handlers
This patch greatly simplifies VMObject locking by doing two things:

1. Giving VMObject an IntrusiveList of all its mapping Region objects.
2. Removing VMObject::m_paging_lock in favor of VMObject::m_lock

Before (1), VMObject::for_each_region() was forced to acquire the
global MM lock (since it worked by walking MemoryManager's list of
all regions and checking for regions that pointed to itself.)

With each VMObject having its own list of Regions, VMObject's own
m_lock is all we need.

Before (2), page fault handlers used a separate mutex for preventing
overlapping work. This design required multiple temporary unlocks
and was generally extremely hard to reason about.

Instead, page fault handlers now use VMObject's own m_lock as well.
2021-07-23 03:24:44 +02:00

45 lines
987 B
C++

/*
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Bitmap.h>
#include <Kernel/UnixTypes.h>
#include <Kernel/VM/VMObject.h>
namespace Kernel {
class InodeVMObject : public VMObject {
public:
virtual ~InodeVMObject() override;
Inode& inode() { return *m_inode; }
Inode const& inode() const { return *m_inode; }
size_t amount_dirty() const;
size_t amount_clean() const;
int release_all_clean_pages();
u32 writable_mappings() const;
u32 executable_mappings() const;
protected:
explicit InodeVMObject(Inode&, size_t);
explicit InodeVMObject(InodeVMObject const&);
InodeVMObject& operator=(InodeVMObject const&) = delete;
InodeVMObject& operator=(InodeVMObject&&) = delete;
InodeVMObject(InodeVMObject&&) = delete;
virtual bool is_inode() const final { return true; }
NonnullRefPtr<Inode> m_inode;
Bitmap m_dirty_pages;
};
}