mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-26 09:30:24 +00:00
Kernel: Make SharedInodeVMObject pages Bitmap allocation OOM-fallible
This commit is contained in:
parent
8030e2a88f
commit
d9d3362722
Notes:
sideshowbarker
2024-07-18 03:35:30 +09:00
Author: https://github.com/IdanHo Commit: https://github.com/SerenityOS/serenity/commit/d9d3362722 Pull-request: https://github.com/SerenityOS/serenity/pull/12422
6 changed files with 26 additions and 22 deletions
|
@ -9,17 +9,17 @@
|
|||
|
||||
namespace Kernel::Memory {
|
||||
|
||||
InodeVMObject::InodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
InodeVMObject::InodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: VMObject(move(new_physical_pages))
|
||||
, m_inode(inode)
|
||||
, m_dirty_pages(Bitmap::try_create(page_count(), false).release_value_but_fixme_should_propagate_errors())
|
||||
, m_dirty_pages(move(dirty_pages))
|
||||
{
|
||||
}
|
||||
|
||||
InodeVMObject::InodeVMObject(InodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
InodeVMObject::InodeVMObject(InodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: VMObject(move(new_physical_pages))
|
||||
, m_inode(other.m_inode)
|
||||
, m_dirty_pages(Bitmap::try_create(page_count(), false).release_value_but_fixme_should_propagate_errors())
|
||||
, m_dirty_pages(move(dirty_pages))
|
||||
{
|
||||
for (size_t i = 0; i < page_count(); ++i)
|
||||
m_dirty_pages.set(i, other.m_dirty_pages.get(i));
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
u32 executable_mappings() const;
|
||||
|
||||
protected:
|
||||
explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
|
||||
InodeVMObject& operator=(InodeVMObject const&) = delete;
|
||||
InodeVMObject& operator=(InodeVMObject&&) = delete;
|
||||
|
|
|
@ -12,22 +12,24 @@ namespace Kernel::Memory {
|
|||
ErrorOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
|
||||
{
|
||||
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(inode.size()));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages)));
|
||||
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
||||
return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages), move(dirty_pages)));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
||||
{
|
||||
auto new_physical_pages = TRY(this->try_clone_physical_pages());
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages)));
|
||||
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages), move(dirty_pages)));
|
||||
}
|
||||
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(inode, move(new_physical_pages))
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: InodeVMObject(inode, move(new_physical_pages), move(dirty_pages))
|
||||
{
|
||||
}
|
||||
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(other, move(new_physical_pages))
|
||||
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: InodeVMObject(other, move(new_physical_pages), move(dirty_pages))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
private:
|
||||
virtual bool is_private_inode() const override { return true; }
|
||||
|
||||
explicit PrivateInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit PrivateInodeVMObject(PrivateInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit PrivateInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
explicit PrivateInodeVMObject(PrivateInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
|
||||
virtual StringView class_name() const override { return "PrivateInodeVMObject"sv; }
|
||||
|
||||
|
|
|
@ -16,7 +16,8 @@ ErrorOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with
|
|||
if (auto shared_vmobject = inode.shared_vmobject())
|
||||
return shared_vmobject.release_nonnull();
|
||||
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(size));
|
||||
auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, move(new_physical_pages))));
|
||||
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
||||
auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, move(new_physical_pages), move(dirty_pages))));
|
||||
vmobject->inode().set_shared_vmobject(*vmobject);
|
||||
return vmobject;
|
||||
}
|
||||
|
@ -24,16 +25,17 @@ ErrorOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with
|
|||
ErrorOr<NonnullRefPtr<VMObject>> SharedInodeVMObject::try_clone()
|
||||
{
|
||||
auto new_physical_pages = TRY(this->try_clone_physical_pages());
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) SharedInodeVMObject(*this, move(new_physical_pages)));
|
||||
auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
|
||||
return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) SharedInodeVMObject(*this, move(new_physical_pages), move(dirty_pages)));
|
||||
}
|
||||
|
||||
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(inode, move(new_physical_pages))
|
||||
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: InodeVMObject(inode, move(new_physical_pages), move(dirty_pages))
|
||||
{
|
||||
}
|
||||
|
||||
SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||
: InodeVMObject(other, move(new_physical_pages))
|
||||
SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
|
||||
: InodeVMObject(other, move(new_physical_pages), move(dirty_pages))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ public:
|
|||
private:
|
||||
virtual bool is_shared_inode() const override { return true; }
|
||||
|
||||
explicit SharedInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit SharedInodeVMObject(SharedInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||
explicit SharedInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
explicit SharedInodeVMObject(SharedInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
|
||||
|
||||
virtual StringView class_name() const override { return "SharedInodeVMObject"sv; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue