Page MenuHomeFreeBSD

vm_page: Fix a logic error in the handling of PQ_ACTIVE operations
ClosedPublic

Authored by markj on Sep 30 2022, 3:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Apr 20, 1:11 AM
Unknown Object (File)
Feb 16 2024, 9:21 AM
Unknown Object (File)
Dec 12 2023, 3:55 PM
Unknown Object (File)
Dec 7 2023, 7:27 AM
Unknown Object (File)
Dec 5 2023, 12:43 AM
Unknown Object (File)
Dec 4 2023, 6:37 PM
Unknown Object (File)
Dec 1 2023, 11:29 AM
Unknown Object (File)
Nov 30 2023, 11:08 PM
Subscribers

Details

Summary

As an optimization, vm_page_activate() avoids requeuing a page that's
already in the active queue. A page's location in the active queue is
mostly unimportant.

When a page is unwired and placed back in the page queues,
vm_page_unwire() avoids moving pages out of PQ_ACTIVE to honour the
request, the idea being that they're likely mapped and so will simply
get bounced back in to PQ_ACTIVE during a queue scan.

In both cases, if the page was logically in PQ_ACTIVE but had not yet
been physically enqueued (i.e., the page is in a per-CPU batch), we
would end up clearing PGA_REQUEUE from the page. Then, batch processing
would ignore the page, so it would end up unwired and not in any queues.
This can arise, for example, when a page is allocated and then
vm_page_activate() is called multiple times in quick succession. The
result is that the page is hidden from the page daemon, so while it will
be freed when its VM object is destroyed, it cannot be reclaimed under
memory pressure.

Fix the bug: when checking if a page is in PQ_ACTIVE, only perform the
optimization if the page is physically enqueued.

Fixes: f3f38e2580f1 ("Start implementing queue state updates using fcmpset loops.")
PR: 256507

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 47658
Build 44545: arc lint + arc unit