Page MenuHomeFreeBSD

vm: use atomic fetchadd in vm_page_sunbusy
ClosedPublic

Authored by mjg on Aug 8 2022, 7:54 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sat, Nov 22, 10:39 PM
Unknown Object (File)
Sat, Nov 22, 5:21 PM
Unknown Object (File)
Sat, Nov 15, 11:19 AM
Unknown Object (File)
Fri, Nov 14, 9:56 PM
Unknown Object (File)
Thu, Nov 13, 4:10 PM
Unknown Object (File)
Fri, Nov 7, 3:49 AM
Unknown Object (File)
Thu, Nov 6, 3:12 PM
Unknown Object (File)
Oct 24 2025, 2:56 AM
Subscribers

Details

Summary

This also fixes a bug where not-last unbusy failed to post a release
fence.

Diff Detail

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

Event Timeline

mjg requested review of this revision.Aug 8 2022, 7:54 PM
mjg created this revision.
markj added inline comments.
sys/vm/vm_page.c
981

We should keep this assertion (and additionally verify that the page is not xbusy).

This revision is now accepted and ready to land.Aug 8 2022, 8:54 PM

The 'lack' of the release fence for non-last sunbusy is intentional, it is only needed for the last unlock.

sys/vm/vm_page.c
981

you want this asserted before or after (as in on the result of fetchadd). note there is already vm_page_assert_sbusied in there

In D36084#819356, @kib wrote:

The 'lack' of the release fence for non-last sunbusy is intentional, it is only needed for the last unlock.

that's the same bug as 890611286ee256314407bbcf64ad74956939eac7

sys/vm/vm_page.c
981

The assertion should be on the state returned by fetchadd.

The existing assertion is looks sufficient, but it's racy and that can easily be fixed.

sys/vm/vm_page.c
981

something of this sort?

x = atomic_fetchadd_int(&m->busy_lock, -VPB_ONE_SHARER);
KASSERT(x != VPB_FREED, ("page %p is freed", m));
KASSERT(x != VPB_UNBUSIED && (x & VPB_BIT_SHARED) != 0,
    ("page %p not sbusied", m));
sys/vm/vm_page.c
981

Looks right to me.

This revision was automatically updated to reflect the committed changes.