diff --git a/Kernel/Memory/PhysicalPage.cpp b/Kernel/Memory/PhysicalPage.cpp index b4890b5c4a..2f5ceb5b9a 100644 --- a/Kernel/Memory/PhysicalPage.cpp +++ b/Kernel/Memory/PhysicalPage.cpp @@ -26,7 +26,7 @@ PhysicalAddress PhysicalPage::paddr() const return MM.get_physical_address(*this); } -void PhysicalPage::free_this() +void PhysicalPage::free_this() const { auto paddr = MM.get_physical_address(*this); if (m_may_return_to_freelist == MayReturnToFreeList::Yes) { diff --git a/Kernel/Memory/PhysicalPage.h b/Kernel/Memory/PhysicalPage.h index 724eb6d5c4..c0869ffb00 100644 --- a/Kernel/Memory/PhysicalPage.h +++ b/Kernel/Memory/PhysicalPage.h @@ -25,12 +25,12 @@ class PhysicalPage { public: PhysicalAddress paddr() const; - void ref() + void ref() const { m_ref_count.fetch_add(1, AK::memory_order_relaxed); } - void unref() + void unref() const { if (m_ref_count.fetch_sub(1, AK::memory_order_acq_rel) == 1) free_this(); @@ -47,9 +47,9 @@ private: explicit PhysicalPage(MayReturnToFreeList may_return_to_freelist); ~PhysicalPage() = default; - void free_this(); + void free_this() const; - Atomic m_ref_count { 1 }; + mutable Atomic m_ref_count { 1 }; MayReturnToFreeList m_may_return_to_freelist { MayReturnToFreeList::Yes }; };