The branch main has been updated by alc:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d394c17baab8f80369775185fa5f32a213bc665e

commit d394c17baab8f80369775185fa5f32a213bc665e
Author:     Alan Cox <[email protected]>
AuthorDate: 2026-12-03 17:43:05 +0000
Commit:     Alan Cox <[email protected]>
CommitDate: 2026-12-04 06:17:09 +0000

    vm_page: Make every shared unbusy a release
    
    vm_page_sunbusy() and vm_page_busy_release() drop a shared busy that
    other threads still hold with a relaxed atomic_fcmpset_int().  Only the
    last sharer's update is a release, but any sharer can modify the page.
    The next thread to busy the page exclusively synchronizes with the last
    sharer's release, so on weakly ordered CPUs it need not see the changes
    by a sharer that was not the last.
    
    Found by:       Claude Code (Opus 5.5)
    Reviewed by:    kib, markj
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D62391
---
 sys/vm/vm_page.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/sys/vm/vm_page.c b/sys/vm/vm_page.c
index b88657d9a21e..e19fe9e707fe 100644
--- a/sys/vm/vm_page.c
+++ b/sys/vm/vm_page.c
@@ -1043,7 +1043,12 @@ vm_page_sunbusy(vm_page_t m)
                KASSERT(x != VPB_FREED,
                    ("vm_page_sunbusy: Unlocking freed page."));
                if (VPB_SHARERS(x) > 1) {
-                       if (atomic_fcmpset_int(&m->busy_lock, &x,
+                       /*
+                        * This sharer may have modified the page, and the
+                        * next thread to busy the page exclusively must see
+                        * those changes.
+                        */
+                       if (atomic_fcmpset_rel_int(&m->busy_lock, &x,
                            x - VPB_ONE_SHARER))
                                break;
                        continue;
@@ -1840,7 +1845,8 @@ vm_page_busy_release(vm_page_t m)
                if (x == VPB_FREED)
                        break;
                if ((x & VPB_BIT_SHARED) != 0 && VPB_SHARERS(x) > 1) {
-                       if (atomic_fcmpset_int(&m->busy_lock, &x,
+                       /* Release, as in vm_page_sunbusy(). */
+                       if (atomic_fcmpset_rel_int(&m->busy_lock, &x,
                            x - VPB_ONE_SHARER))
                                break;
                        continue;

Reply via email to