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)
Fri, Apr 12, 3:03 AM
Unknown Object (File)
Feb 20 2024, 6:12 PM
Unknown Object (File)
Jan 12 2024, 3:08 AM
Unknown Object (File)
Dec 26 2023, 8:07 AM
Unknown Object (File)
Nov 23 2023, 6:11 AM
Unknown Object (File)
Nov 8 2023, 4:09 PM
Unknown Object (File)
Sep 12 2023, 11:24 AM
Unknown Object (File)
Aug 10 2023, 3:43 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.