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)
Nov 12 2024, 8:09 PM
Unknown Object (File)
Sep 24 2024, 7:54 PM
Unknown Object (File)
Sep 24 2024, 3:59 PM
Unknown Object (File)
Sep 22 2024, 7:35 PM
Unknown Object (File)
Sep 21 2024, 11:02 AM
Unknown Object (File)
Sep 21 2024, 1:54 AM
Unknown Object (File)
Sep 19 2024, 7:43 PM
Unknown Object (File)
Sep 17 2024, 3:26 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.