Author: jah
Date: Sat Jan 21 06:48:52 2017
New Revision: 312561
URL: https://svnweb.freebsd.org/changeset/base/312561
Log:
  MFC r312153, r312191
  
  r312153:
  
    For i386 temporary mappings, unpin the thread before releasing
    the cmap lock.  Releasing the lock first may result in the thread
    being immediately rescheduled and bound to the same CPU, only to
    unpin itself upon resuming execution.
  
    Noted by:   skra (in review for armv6 equivalent)
  
  r312191:
  
    Add comment explaining relative order of sched_unpin() and mtx_unlock().
  
    Suggested by:       alc

Modified:
  stable/11/sys/i386/i386/pmap.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/i386/i386/pmap.c
==============================================================================
--- stable/11/sys/i386/i386/pmap.c      Fri Jan 20 22:41:16 2017        
(r312560)
+++ stable/11/sys/i386/i386/pmap.c      Sat Jan 21 06:48:52 2017        
(r312561)
@@ -4231,8 +4231,14 @@ pmap_zero_page(vm_page_t m)
        invlcaddr(pc->pc_cmap_addr2);
        pagezero(pc->pc_cmap_addr2);
        *cmap_pte2 = 0;
-       mtx_unlock(&pc->pc_cmap_lock);
+
+       /*
+        * Unpin the thread before releasing the lock.  Otherwise the thread
+        * could be rescheduled while still bound to the current CPU, only
+        * to unpin itself immediately upon resuming execution.
+        */
        sched_unpin();
+       mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -4261,8 +4267,8 @@ pmap_zero_page_area(vm_page_t m, int off
        else
                bzero(pc->pc_cmap_addr2 + off, size);
        *cmap_pte2 = 0;
-       mtx_unlock(&pc->pc_cmap_lock);
        sched_unpin();
+       mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -4316,8 +4322,8 @@ pmap_copy_page(vm_page_t src, vm_page_t 
        bcopy(pc->pc_cmap_addr1, pc->pc_cmap_addr2, PAGE_SIZE);
        *cmap_pte1 = 0;
        *cmap_pte2 = 0;
-       mtx_unlock(&pc->pc_cmap_lock);
        sched_unpin();
+       mtx_unlock(&pc->pc_cmap_lock);
 }
 
 int unmapped_buf_allowed = 1;
@@ -4364,8 +4370,8 @@ pmap_copy_pages(vm_page_t ma[], vm_offse
        }
        *cmap_pte1 = 0;
        *cmap_pte2 = 0;
-       mtx_unlock(&pc->pc_cmap_lock);
        sched_unpin();
+       mtx_unlock(&pc->pc_cmap_lock);
 }
 
 /*
@@ -5349,8 +5355,8 @@ pmap_flush_page(vm_page_t m)
                if (useclflushopt || cpu_vendor_id != CPU_VENDOR_INTEL)
                        mfence();
                *cmap_pte2 = 0;
-               mtx_unlock(&pc->pc_cmap_lock);
                sched_unpin();
+               mtx_unlock(&pc->pc_cmap_lock);
        } else
                pmap_invalidate_cache();
 }
_______________________________________________
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