Page MenuHomeFreeBSD

vm_page: separate validated from unlocked lookup
ClosedPublic

Authored by dougm on Oct 7 2024, 10:11 PM.
Tags
None
Referenced Files
F107488261: D47001.diff
Tue, Jan 14, 10:30 PM
Unknown Object (File)
Sun, Jan 5, 9:33 PM
Unknown Object (File)
Dec 8 2024, 10:59 AM
Unknown Object (File)
Nov 23 2024, 12:40 PM
Unknown Object (File)
Nov 21 2024, 6:32 AM
Unknown Object (File)
Nov 6 2024, 1:58 PM
Unknown Object (File)
Nov 6 2024, 7:15 AM
Unknown Object (File)
Nov 3 2024, 10:21 PM
Subscribers

Details

Summary

Function vm_page_acquire_unlocked both looks up pages and validates them. Much of it serves the needs of only one caller, vm_page_grab_pages_unlocked. Extract from that function the parts that serve vm_page_grab_pages_unlocked, and move them into that function.

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

dougm requested review of this revision.Oct 7 2024, 10:11 PM
dougm created this revision.
sys/vm/vm_page.c
4825

I think it is more natural to put spinwait() into the loop body, i.e. in the 'case VMPV_RETRY' switch label. It is strange to see this in the code that does not loop.

5014

All three loops are only different by the return statement, am I right?

Then might be, introduce a helper function that returns bool to indicate success/failure, and takes vm_page_t *mp, to return m? The function would handle the looping:

static bool
vm_page_lookup_validate(vm_page_t *mp, pindex, flags)
{
  while ((m = vm_page_lookup_unlocked(object, pindex)) != NULL) {
           switch (vm_page_validate(object, pindex, m, flags)) {
                case VMPV_SUCCESS:
                        *mp = m;
                        return (true);
                case VMPV_RETRY:
                        continue;
                case VMPV_FAILURE:
                        return (false);
}
  *mp = NULL;
   return (true);
}
dougm edited the summary of this revision. (Show Details)

Restore the name vm_page_acquire_unlocked and have it do the looping. Drop the enums.

This revision is now accepted and ready to land.Oct 14 2024, 9:40 PM
This revision was automatically updated to reflect the committed changes.