]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
vm_page: Fix a logic error in the handling of PQ_ACTIVE operations
authorMark Johnston <markj@FreeBSD.org>
Wed, 5 Oct 2022 19:12:46 +0000 (15:12 -0400)
committerMark Johnston <markj@FreeBSD.org>
Tue, 1 Nov 2022 13:28:11 +0000 (09:28 -0400)
commit4867d7d34dfd54986d5798eddc3ce92a70cc9841
treed7cc78763eb741d1b28ed481d311fb176b1b9e66
parent7ab877cb3f9d55a394e43a2c1a1e2711df12226d
vm_page: Fix a logic error in the handling of PQ_ACTIVE operations

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.

Approved by: so
Security: FreeBSD-EN-22:23.vm
PR: 256507
Fixes: f3f38e2580f1 ("Start implementing queue state updates using fcmpset loops.")
Reviewed by: alc, kib
Sponsored by: E-CARD Ltd.
Sponsored by: Klara, Inc.

(cherry picked from commit 2c9dc2384f85a4ccc44a79b349f4fb0253a2f254)
(cherry picked from commit 6094749a1a5dafb8daf98deab23fc968070bc695)
sys/vm/vm_page.c