Page MenuHomeFreeBSD

vm_page_advise(): reformat conditional statements
Needs ReviewPublic

Authored by mhorne on Nov 8 2023, 7:01 PM.
Tags
None
Referenced Files
Unknown Object (File)
Dec 25 2023, 5:01 PM
Unknown Object (File)
Dec 21 2023, 6:52 AM
Unknown Object (File)
Dec 20 2023, 8:27 AM
Unknown Object (File)
Dec 15 2023, 7:16 AM
Unknown Object (File)
Nov 28 2023, 8:16 PM
Unknown Object (File)
Nov 28 2023, 7:21 PM
Unknown Object (File)
Nov 28 2023, 4:53 AM
Unknown Object (File)
Nov 22 2023, 9:32 AM
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);
...