Page MenuHomeFreeBSD

(vm object 4) Wrap valid accesses in inlines. Add missing busy acquires to protect valid.
ClosedPublic

Authored by jeff on Sep 10 2019, 8:11 PM.

Details

Summary

This patch wraps canonically protected valid bit access in inlines and leaves those that have special protection without. It slightly expands the scope of busy to ensure that all valid manipulation is done with a busy lock. In the case of a shared busy lock we use atomic updates to the valid field as we do with dirty. The following guarantees exist after this:

valid is always set with busy held.
valid is always cleared with busy and the object lock held.
valid is reliably checked against zero with either object or busy.

The first clause should be clear. Before we may not have held the busy lock but it had been guaranteed that it was not otherwise held which is logically the same as holding it.

The second clause exists because some callers like vm_map_pmap_enter() want to enter valid pages without checking the busy state. Fortunately valid is only cleared on truncate and pageout so effectively the object lock requirement is rare.

Diff Detail

Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 26888
Build 25202: arc lint + arc unit

Event Timeline

jeff created this revision.Sep 10 2019, 8:11 PM
jeff retitled this revision from Wrap valid accesses in inlines. Add missing busy acquires to protect valid. to (vm object 4) Wrap valid accesses in inlines. Add missing busy acquires to protect valid..Sep 10 2019, 8:19 PM
jeff edited the summary of this revision. (Show Details)
jeff added reviewers: alc, kib, markj, dougm.
jeff added inline comments.Sep 19 2019, 9:34 PM
sys/vm/vm_page.h
162

s/speculativey/speculative/

179

Need to clean up wording here.

kib added a comment.Sep 22 2019, 1:05 PM

What do you mean by a note that pageout clears valid state of the page ? I thought that pageout laundries the page, and a clean page might be freed for reuse. In other words, valid bits can be only trimmed by truncation either of the vnode or swap backing OBJ_NOSPLIT object.

sys/vm/vm_page.c
4899

invoke

jeff added a comment.Sep 25 2019, 11:27 PM
In D21594#474564, @kib wrote:

What do you mean by a note that pageout clears valid state of the page ? I thought that pageout laundries the page, and a clean page might be freed for reuse. In other words, valid bits can be only trimmed by truncation either of the vnode or swap backing OBJ_NOSPLIT object.

Well a clean valid page will change identity and become invalid via pageout. That was more my meaning. I can clarify that text.

Your understanding is the same as mine regarding the remainder.

kib accepted this revision.Sep 26 2019, 8:57 PM
This revision is now accepted and ready to land.Sep 26 2019, 8:57 PM
markj accepted this revision.Sep 26 2019, 9:10 PM
markj added inline comments.
sys/vm/vm_page.h
151

Missing parens after pmap_remove_all().

Isn't pmap_remove_write() also sufficient?

966

[Bikeshedding] vm_page_any_valid(), with the sense inverted, reads better to me.

jeff updated this revision to Diff 62941.EditedOct 5 2019, 7:49 PM

Rewrote the vm_page.h locking description.

This revision now requires review to proceed.Oct 5 2019, 7:49 PM
markj accepted this revision.Oct 7 2019, 6:56 PM
This revision is now accepted and ready to land.Oct 7 2019, 6:56 PM
kib accepted this revision.Oct 8 2019, 8:39 AM
jeff closed this revision.Oct 15 2019, 3:59 AM