Page MenuHomeFreeBSD

vm_page: separate validated from unlocked lookup
ClosedPublic

Authored by dougm on Oct 7 2024, 10:11 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Oct 3, 1:39 AM
Unknown Object (File)
Sep 4 2025, 7:29 PM
Unknown Object (File)
Sep 3 2025, 6:55 PM
Unknown Object (File)
Sep 3 2025, 4:23 AM
Unknown Object (File)
Sep 1 2025, 5:18 AM
Unknown Object (File)
Sep 1 2025, 2:01 AM
Unknown Object (File)
Aug 29 2025, 2:33 AM
Unknown Object (File)
Aug 26 2025, 2:34 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.Oct 7 2024, 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.Oct 14 2024, 9:40 PM
This revision was automatically updated to reflect the committed changes.