Page MenuHomeFreeBSD

Augment vm_page_grab to support more cases that want to acquire busy locks.
AbandonedPublic

Authored by jeff on Aug 20 2019, 1:04 AM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Apr 25, 9:23 PM
Unknown Object (File)
Feb 1 2024, 2:47 AM
Unknown Object (File)
Dec 20 2023, 5:22 AM
Unknown Object (File)
Nov 22 2023, 11:45 AM
Unknown Object (File)
Nov 13 2023, 7:15 PM
Unknown Object (File)
Nov 13 2023, 3:44 AM
Unknown Object (File)
Nov 11 2023, 7:26 PM
Unknown Object (File)
Sep 3 2023, 1:02 AM
Subscribers

Details

Reviewers
alc
kib
markj
dougm
Summary

This patch adds two new flags, VM_ALLOC_NOCREAT & VM_ALLOC_VALID, so that we can move more consumers to grab() and eliminate hand-rolled loops with sensitive synchronization.

NOCREAT does the lookup/busy/wire in a loop but fails if it has to allocate a page.
VALID only returns existing valid pages.

There are other callers which can be refactored into this paradigm later.

The second part of the patch implements vm_page_busy_acquire() which does a looping busy acquire so callers are not coding their own sleep_if_busy() loops or blindly calling vm_page_xbusy() and expecting it to succeed.

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 25969
Build 24525: arc lint + arc unit

Event Timeline

jeff retitled this revision from Augment vm_page_grab to support more cases that want to acquire busy locks. Add a new function, vm_page_busy_acquire(), to support others. to Augment vm_page_grab to support more cases that want to acquire busy locks..Aug 20 2019, 1:09 AM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: alc, kib, markj, dougm.
sys/vm/vm_page.c
3895

Why do you changed the setting of PGA_REFERENCED ?

3921

It is somewhat strange semantic. If only ALLOC_VALID was specified, without ALLOC_NOCREAT, why zeroed page cannot satisfy the caller ?

sys/vm/vm_page.c
3895

I flipped this the wrong way. It should be NOCREAT == 0.

Truncate, for example, wants to grab the last page to zero it, but only if it already exists. If not the pager will do it properly when it's created and you just waste time paging in an unnecessary page.

3921

I overloaded the VALID name. I think we could use a different name for VM_ALLOC_VALID.

It basically means, only return an existing valid page, but do no work to make it valid.

There are some other weirdnesses. For example, vm_page_grab_pages() will set the page bits valid when it zeros a page. vm_page_grab() does not.

I like this api layer that allows us to centralize synchronization but I feel at some point it could be simplified and split into a few smaller functions. The swiss army knife of flags always gets confusing.

sys/vm/vm_page.c
3895

How about ALLOC_IFVALID

sys/vm/vm_page.c
3895

I still do not see why would we remove protection against pagedaemon during the sleep. We did found the page, so why NOCREAT/IFVALID should make it more likely for the page to be reclaimed under us, while we sleep for busy ?

3921

I understand this, my point is that allocating a page is much more work than validate it by zeroing.