Page MenuHomeFreeBSD

vm_fault: drop never-true busy_sleep test
ClosedPublic

Authored by dougm on Jul 6 2025, 4:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Oct 12, 12:34 AM
Unknown Object (File)
Sun, Oct 12, 12:34 AM
Unknown Object (File)
Sun, Oct 12, 12:34 AM
Unknown Object (File)
Sat, Oct 11, 3:02 PM
Unknown Object (File)
Thu, Oct 9, 9:19 PM
Unknown Object (File)
Wed, Oct 8, 9:25 PM
Unknown Object (File)
Sat, Oct 4, 11:16 AM
Unknown Object (File)
Thu, Oct 2, 1:34 PM
Subscribers

Details

Summary

vm_fault_busy_sleep() tests to see whether the page fs->m matches the value looked up at fs->pindex. At that point, a lock is held on fs->object, and it has been held since before vm_fault_object() also looked up fs->pindex in fs->object and stored the result in fs->m. So the values must match, and the test is not necessary. Drop it.

Test Plan

Replacing the useless test with an assertion, and asserting that the two values match instead, produced no assertion failures in running the first 204 (and counting) stress2 tests.

Diff Detail

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

Event Timeline

dougm requested review of this revision.Jul 6 2025, 4:41 PM
dougm created this revision.
This revision is now accepted and ready to land.Jul 6 2025, 5:51 PM

Then why not convert the check into the assertion in the final patch too? IMO it is good to have, since the path from lookup to this busy_sleep() line is somewhat long.

This lookup originated here:

commit 87b646630c4892e21446cd096bea6bcaecea33ac
Author: Mark Johnston <markj@FreeBSD.org>
Date:   Mon Nov 15 11:35:44 2021 -0500

    vm_page: Consolidate page busy sleep mechanisms
    
    - Modify vm_page_busy_sleep() and vm_page_busy_sleep_unlocked() to take
      a VM_ALLOC_* flag indicating whether to sleep on shared-busy, and fix
      up callers.
    - Modify vm_page_busy_sleep() to return a status indicating whether the
      object lock was dropped, and fix up callers.
    - Convert callers of vm_page_sleep_if_busy() to use vm_page_busy_sleep()
      instead.
    - Remove vm_page_sleep_if_(x)busy().
    
    No functional change intended.
    
    Obtained from:  jeff (object_concurrency patches)
    Reviewed by:    kib
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D32947
In D51179#1168325, @alc wrote:

This lookup originated here:

commit 87b646630c4892e21446cd096bea6bcaecea33ac
Author: Mark Johnston <markj@FreeBSD.org>
Date:   Mon Nov 15 11:35:44 2021 -0500

    vm_page: Consolidate page busy sleep mechanisms
    
    - Modify vm_page_busy_sleep() and vm_page_busy_sleep_unlocked() to take
      a VM_ALLOC_* flag indicating whether to sleep on shared-busy, and fix
      up callers.
    - Modify vm_page_busy_sleep() to return a status indicating whether the
      object lock was dropped, and fix up callers.
    - Convert callers of vm_page_sleep_if_busy() to use vm_page_busy_sleep()
      instead.
    - Remove vm_page_sleep_if_(x)busy().
    
    No functional change intended.
    
    Obtained from:  jeff (object_concurrency patches)
    Reviewed by:    kib
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D32947

This lookup was first introduced between stable/4 and stable/6. The lookup was needed in the latter because we were dropping and reacquiring the object lock around the map unlock and possible vput().

In D51179#1168320, @kib wrote:

Then why not convert the check into the assertion in the final patch too? IMO it is good to have, since the path from lookup to this busy_sleep() line is somewhat long.

I don't want to vm_page_lookup appear here without cause, since it would have to be changed to vm_page_lookup_readonly in a future potential change.

In D51179#1168320, @kib wrote:

Then why not convert the check into the assertion in the final patch too? IMO it is good to have, since the path from lookup to this busy_sleep() line is somewhat long.

Because I don't want to have to change this function again in a few days when/if vm_page_lookup_readonly is introduced.

This revision was automatically updated to reflect the committed changes.
In D51179#1168320, @kib wrote:

Then why not convert the check into the assertion in the final patch too? IMO it is good to have, since the path from lookup to this busy_sleep() line is somewhat long.

Because I don't want to have to change this function again in a few days when/if vm_page_lookup_readonly is introduced.

You could assert fs->m->pindex == fs->pindex.