Author: kib
Date: Tue Oct 18 10:33:28 2016
New Revision: 307555
URL: https://svnweb.freebsd.org/changeset/base/307555

Log:
  MFC r307064:
  When downgrading exclusively busied page to shared-busy state, wakeup
  waiters.

Modified:
  stable/10/sys/vm/vm_page.c
Directory Properties:
  stable/10/   (props changed)

Modified: stable/10/sys/vm/vm_page.c
==============================================================================
--- stable/10/sys/vm/vm_page.c  Tue Oct 18 10:20:58 2016        (r307554)
+++ stable/10/sys/vm/vm_page.c  Tue Oct 18 10:33:28 2016        (r307555)
@@ -515,15 +515,26 @@ void
 vm_page_busy_downgrade(vm_page_t m)
 {
        u_int x;
+       bool locked;
 
        vm_page_assert_xbusied(m);
+       locked = mtx_owned(vm_page_lockptr(m));
 
        for (;;) {
                x = m->busy_lock;
                x &= VPB_BIT_WAITERS;
+               if (x != 0 && !locked)
+                       vm_page_lock(m);
                if (atomic_cmpset_rel_int(&m->busy_lock,
-                   VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1) | x))
+                   VPB_SINGLE_EXCLUSIVER | x, VPB_SHARERS_WORD(1)))
                        break;
+               if (x != 0 && !locked)
+                       vm_page_unlock(m);
+       }
+       if (x != 0) {
+               wakeup(m);
+               if (!locked)
+                       vm_page_unlock(m);
        }
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to