svn commit: r280324 - head/sys/arm/arm

Olivier Houchard cognet at FreeBSD.org
Sat Mar 21 15:33:01 UTC 2015


Author: cognet
Date: Sat Mar 21 15:32:59 2015
New Revision: 280324
URL: https://svnweb.freebsd.org/changeset/base/280324

Log:
  When waiting on PTE allocation, another thread could free the l2_dtable while
  we're not looking at it.
  Fix this by increasing l2->l2_occupancy before we try to alloc (and decrease
  it if the allocation failed, or if another thread did a similar allocation).
  
  Submitted by:	Kohji Okuno <okuno.kohji at jp.panasonic.com>
  MFC after:	1 week

Modified:
  head/sys/arm/arm/pmap-v6.c
  head/sys/arm/arm/pmap.c

Modified: head/sys/arm/arm/pmap-v6.c
==============================================================================
--- head/sys/arm/arm/pmap-v6.c	Sat Mar 21 15:01:19 2015	(r280323)
+++ head/sys/arm/arm/pmap-v6.c	Sat Mar 21 15:32:59 2015	(r280324)
@@ -758,6 +758,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off
 		 * No L2 page table has been allocated. Chances are, this
 		 * is because we just allocated the l2_dtable, above.
 		 */
+		l2->l2_occupancy++;
 		PMAP_UNLOCK(pmap);
 		rw_wunlock(&pvh_global_lock);
 		ptep = uma_zalloc(l2zone, M_NOWAIT);
@@ -765,6 +766,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off
 		PMAP_LOCK(pmap);
 		if (l2b->l2b_kva != 0) {
 			/* We lost the race. */
+			l2->l2_occupancy--;
 			uma_zfree(l2zone, ptep);
 			return (l2b);
 		}
@@ -775,6 +777,7 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off
 			 * time. We may need to deallocate the l2_dtable
 			 * if we allocated a new one above.
 			 */
+			l2->l2_occupancy--;
 			if (l2->l2_occupancy == 0) {
 				pmap->pm_l2[L2_IDX(l1idx)] = NULL;
 				uma_zfree(l2table_zone, l2);
@@ -782,7 +785,6 @@ pmap_alloc_l2_bucket(pmap_t pmap, vm_off
 			return (NULL);
 		}
 
-		l2->l2_occupancy++;
 		l2b->l2b_kva = ptep;
 		l2b->l2b_l1idx = l1idx;
 	}

Modified: head/sys/arm/arm/pmap.c
==============================================================================
--- head/sys/arm/arm/pmap.c	Sat Mar 21 15:01:19 2015	(r280323)
+++ head/sys/arm/arm/pmap.c	Sat Mar 21 15:32:59 2015	(r280324)
@@ -878,6 +878,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse
 		 * No L2 page table has been allocated. Chances are, this
 		 * is because we just allocated the l2_dtable, above.
 		 */
+		l2->l2_occupancy++;
 		PMAP_UNLOCK(pm);
 		rw_wunlock(&pvh_global_lock);
 		ptep = uma_zalloc(l2zone, M_NOWAIT);
@@ -885,6 +886,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse
 		PMAP_LOCK(pm);
 		if (l2b->l2b_kva != 0) {
 			/* We lost the race. */
+			l2->l2_occupancy--;
 			uma_zfree(l2zone, ptep);
 			return (l2b);
 		}
@@ -895,6 +897,7 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse
 			 * time. We may need to deallocate the l2_dtable
 			 * if we allocated a new one above.
 			 */
+			l2->l2_occupancy--;
 			if (l2->l2_occupancy == 0) {
 				pm->pm_l2[L2_IDX(l1idx)] = NULL;
 				uma_zfree(l2table_zone, l2);
@@ -902,7 +905,6 @@ pmap_alloc_l2_bucket(pmap_t pm, vm_offse
 			return (NULL);
 		}
 
-		l2->l2_occupancy++;
 		l2b->l2b_kva = ptep;
 		l2b->l2b_l1idx = l1idx;
 	}


More information about the svn-src-all mailing list