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.
Tags
None
Referenced Files
Unknown Object (File)
Jan 14 2024, 5:20 AM
Unknown Object (File)
Jan 10 2024, 6:18 AM
Unknown Object (File)
Jan 10 2024, 6:18 AM
Unknown Object (File)
Jan 10 2024, 6:18 AM
Unknown Object (File)
Jan 10 2024, 6:06 AM
Unknown Object (File)
Dec 20 2023, 4:43 AM
Unknown Object (File)
Aug 31 2023, 7:40 AM
Unknown Object (File)
Aug 31 2023, 7:39 AM
Subscribers

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 Passed
Unit
No Test Coverage
Build Status
Buildable 26888
Build 25202: arc lint + arc unit

Event Timeline

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.
sys/vm/vm_page.h
162

s/speculativey/speculative/

179

Need to clean up wording here.

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

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.

This revision is now accepted and ready to land.Sep 26 2019, 8:57 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.

Rewrote the vm_page.h locking description.

This revision now requires review to proceed.Oct 5 2019, 7:49 PM
This revision is now accepted and ready to land.Oct 7 2019, 6:56 PM