Page MenuHomeFreeBSD

Fix racy checks of m->queue.
ClosedPublic

Authored by markj on May 3 2018, 3:00 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 3, 12:50 AM
Unknown Object (File)
Nov 8 2023, 5:57 AM
Unknown Object (File)
Oct 7 2023, 4:54 AM
Unknown Object (File)
Sep 22 2023, 3:54 AM
Unknown Object (File)
Jul 29 2023, 1:41 AM
Unknown Object (File)
May 27 2023, 10:26 AM
Unknown Object (File)
Dec 26 2022, 11:04 PM
Unknown Object (File)
Dec 21 2022, 1:00 PM
Subscribers

Details

Summary

r332974 was somewhat sloppy in that I did not properly audit callers of
vm_page_active() and so on. Code like the following is racy after that
revision:

vm_page_assert_locked(m);
if (m->queue == PQ_ACTIVE)
	vm_page_reference(m);
else
	vm_page_requeue(m);

in particular, PGA_DEQUEUE might be set on m, in which case m->queue
may change to PQ_NONE after the vm_page_active() call but before the
vm_page_requeue() call. (Note that once m->queue has transitioned to
PQ_NONE, the page lock prevents further updates to the queue field.)

Add a function, vm_page_queue(), which reads m->queue with the
appropriate synchronization. It requires the page lock. Use this
function where appropriate.

Test Plan

pho found the issue (manifested as an assertion failure in vm_page_requeue()) and verified the patch.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj edited the test plan for this revision. (Show Details)
markj added reviewers: alc, kib, jeff.
This revision is now accepted and ready to land.May 4 2018, 2:50 PM
This revision was automatically updated to reflect the committed changes.