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)
Wed, May 20, 11:40 AM
Unknown Object (File)
Wed, May 13, 10:26 PM
Unknown Object (File)
Wed, May 13, 10:26 PM
Unknown Object (File)
Wed, May 13, 10:19 PM
Unknown Object (File)
Thu, May 7, 12:19 AM
Unknown Object (File)
May 4 2026, 9:00 AM
Unknown Object (File)
May 3 2026, 9:08 PM
Unknown Object (File)
May 3 2026, 6:18 PM
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.