summaryrefslogtreecommitdiff
path: root/Kernel/VM/PhysicalPage.h
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-22 16:34:11 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-22 16:34:11 +0200
commit0db7e04c2ebcd16a948523be5a7dbb024ab1d7c4 (patch)
tree4a75c1108e1b607a5731a5100b9c932f56fddb5f /Kernel/VM/PhysicalPage.h
parent23f335bcd7d31e827f1a5fbda5e210721dcae813 (diff)
downloadserenity-0db7e04c2ebcd16a948523be5a7dbb024ab1d7c4.zip
Revert "Kernel: Make PhysicalPage not movable and use atomic ref counting"
This reverts commit a89ccd842becdfbc951436da5384d8819374e0f4.
Diffstat (limited to 'Kernel/VM/PhysicalPage.h')
-rw-r--r--Kernel/VM/PhysicalPage.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/Kernel/VM/PhysicalPage.h b/Kernel/VM/PhysicalPage.h
index 92dcd20e24..498ce7dd03 100644
--- a/Kernel/VM/PhysicalPage.h
+++ b/Kernel/VM/PhysicalPage.h
@@ -39,29 +39,29 @@ class PhysicalPage {
friend class PageDirectory;
friend class VMObject;
- MAKE_SLAB_ALLOCATED(PhysicalPage);
- AK_MAKE_NONMOVABLE(PhysicalPage);
-
+ MAKE_SLAB_ALLOCATED(PhysicalPage)
public:
PhysicalAddress paddr() const { return m_paddr; }
void ref()
{
- m_ref_count.fetch_add(1, AK::memory_order_acq_rel);
+ ASSERT(m_ref_count);
+ ++m_ref_count;
}
void unref()
{
- if (m_ref_count.fetch_sub(1, AK::memory_order_acq_rel) == 1) {
+ ASSERT(m_ref_count);
+ if (!--m_ref_count) {
if (m_may_return_to_freelist)
- return_to_freelist();
+ move(*this).return_to_freelist();
delete this;
}
}
static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);
- u32 ref_count() const { return m_ref_count.load(AK::memory_order_consume); }
+ u32 ref_count() const { return m_ref_count; }
bool is_shared_zero_page() const;
@@ -69,9 +69,9 @@ private:
PhysicalPage(PhysicalAddress paddr, bool supervisor, bool may_return_to_freelist = true);
~PhysicalPage() {}
- void return_to_freelist() const;
+ void return_to_freelist() &&;
- Atomic<u32> m_ref_count { 1 };
+ u32 m_ref_count { 1 };
bool m_may_return_to_freelist { true };
bool m_supervisor { false };
PhysicalAddress m_paddr;