Skip to content

Commit

Permalink
Kernel: Widen PhysicalPage refcount to 32 bits
Browse files Browse the repository at this point in the history
A 16-bit refcount is just begging for trouble right nowl.
A 32-bit refcount will be begging for trouble later down the line,
so we'll have to revisit this eventually. :^)
  • Loading branch information
awesomekling committed Feb 15, 2020
1 parent 51628f6 commit 5507945
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Kernel/VM/PhysicalPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void PhysicalPage::return_to_freelist() &&

InterruptDisabler disabler;

m_retain_count = 1;
m_ref_count = 1;

if (m_supervisor)
MM.deallocate_supervisor_physical_page(move(*this));
Expand Down
12 changes: 6 additions & 6 deletions Kernel/VM/PhysicalPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ class PhysicalPage {

void ref()
{
ASSERT(m_retain_count);
++m_retain_count;
ASSERT(m_ref_count);
++m_ref_count;
}

void unref()
{
ASSERT(m_retain_count);
if (!--m_retain_count) {
ASSERT(m_ref_count);
if (!--m_ref_count) {
if (m_may_return_to_freelist)
move(*this).return_to_freelist();
delete this;
Expand All @@ -58,7 +58,7 @@ class PhysicalPage {

static NonnullRefPtr<PhysicalPage> create(PhysicalAddress, bool supervisor, bool may_return_to_freelist = true);

u16 ref_count() const { return m_retain_count; }
u32 ref_count() const { return m_ref_count; }

bool is_shared_zero_page() const;

Expand All @@ -68,7 +68,7 @@ class PhysicalPage {

void return_to_freelist() &&;

u16 m_retain_count { 1 };
u32 m_ref_count { 1 };
bool m_may_return_to_freelist { true };
bool m_supervisor { false };
PhysicalAddress m_paddr;
Expand Down

0 comments on commit 5507945

Please sign in to comment.