Page MenuHomeFreeBSD

vm_page: separate validated from unlocked lookup
ClosedPublic

Authored by dougm on Mon, Oct 7, 10:11 PM.
Tags
None
Referenced Files
F100256560: D47001.diff
Tue, Oct 15, 4:37 AM
Unknown Object (File)
Wed, Oct 9, 10:20 AM
Unknown Object (File)
Wed, Oct 9, 12:38 AM
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

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

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

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.

5013

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.Mon, Oct 14, 9:40 PM
This revision was automatically updated to reflect the committed changes.