Page MenuHomeFreeBSD

vm_page_advise(): reformat conditional statements
Needs ReviewPublic

Authored by mhorne on Nov 8 2023, 7:01 PM.
Tags
None
Referenced Files
F170556852: D42513.id.diff
Sat, Sep 5, 9:49 AM
F170547611: D42513.id129873.diff
Sat, Sep 5, 8:41 AM
F170419465: D42513.diff
Fri, Sep 4, 6:10 PM
F170410485: D42513.diff
Fri, Sep 4, 5:05 PM
F170409215: D42513.id129873.diff
Fri, Sep 4, 4:56 PM
Unknown Object (File)
Fri, Sep 4, 1:21 PM
Unknown Object (File)
Thu, Sep 3, 4:43 AM
Unknown Object (File)
Wed, Sep 2, 1:33 PM
Subscribers

Details

Reviewers
markj
kib
alc
dougm
Summary

Use a switch, for better enumeration of the possible values. This is
non-functional change, but IMO it makes the logic a little easier to
follow.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 54337
Build 51227: arc lint + arc unit

Event Timeline

mhorne requested review of this revision.Nov 8 2023, 7:01 PM
sys/vm/vm_page.c
4453

Suppose that advise is MADV_WILLNEED. Before the patch, the page is dirtied if pmap thinks it is modified.

sys/vm/vm_page.c
4453

If advise is MADV_WILLNEED, we don't get to this point. We return on line 4450.

sys/vm/vm_page.c
4459

This change simplifies the control flow, but I don't know that the code is really clearer. The handling the dirty bits for MADV_FREE/DONTNEED above is connected to the rest of the function below, but that's not obvious. I think this would be the easiest to follow:

if (advice != MADV_DONTNEED && advice != MADV_FREE) {
    if (advice == MADV_WILLNEED)
        vm_page_activate(m);
    return;
}

if (advice == MADV_FREE)
    vm_page_undirty(m);
else if (m->dirty == 0 && pmap_is_modified(m))
    vm_page_dirty(m);
...