PMAP_LOCK_DESTROY() vs. vmspace UMA_ZONE_NOFREE

Svatopluk Kraus onwahe at gmail.com
Fri Aug 15 13:20:31 UTC 2014


Hi,

I was playing with ports/benchmarks/forkbomb while testing my and Michal's
armv6 pmap based on i386 one when I found - IMHO - sketelot in the closet.

i386, xen, and sparc64 pmaps call PMAP_LOCK_DESTROY() in pmap_pinit() if
some allocation failed. As vmspace (struct pmap is part of it) uma zone is
created with UMA_ZONE_NOFREE flag and PMAP_LOCK_INIT() is called from
vmspace_zinit() initiator, PMAP_LOCK_DESTROY() should be called from
nowhere.

The pmap_c_patch.txt is attached to solve it.

IMHO, I think that definition of PMAP_LOCK_DESTROY() is misleading a little
as PMAP_LOCK_DESTROY() cannot be used anywhere as long as UMA_ZONE_NOFREE
flag is used.

The pmap_all_patch.txt is attach to wipe PMAP_LOCK_DESTROY() out of source
tree.

Svata
-------------- next part --------------
Index: sys/i386/i386/pmap.c
===================================================================
--- sys/i386/i386/pmap.c	(revision 270020)
+++ sys/i386/i386/pmap.c	(working copy)
@@ -1755,10 +1755,8 @@
 	 */
 	if (pmap->pm_pdir == NULL) {
 		pmap->pm_pdir = (pd_entry_t *)kva_alloc(NBPTD);
-		if (pmap->pm_pdir == NULL) {
-			PMAP_LOCK_DESTROY(pmap);
+		if (pmap->pm_pdir == NULL)
 			return (0);
-		}
 #ifdef PAE
 		pmap->pm_pdpt = uma_zalloc(pdptzone, M_WAITOK | M_ZERO);
 		KASSERT(((vm_offset_t)pmap->pm_pdpt &
Index: sys/i386/xen/pmap.c
===================================================================
--- sys/i386/xen/pmap.c	(revision 270020)
+++ sys/i386/xen/pmap.c	(working copy)
@@ -1459,7 +1459,6 @@
 	if (pmap->pm_pdir == NULL) {
 		pmap->pm_pdir = (pd_entry_t *)kva_alloc(NBPTD);
 		if (pmap->pm_pdir == NULL) {
-			PMAP_LOCK_DESTROY(pmap);
 #ifdef HAMFISTED_LOCKING
 			mtx_unlock(&createdelete_lock);
 #endif
Index: sys/sparc64/sparc64/pmap.c
===================================================================
--- sys/sparc64/sparc64/pmap.c	(revision 270020)
+++ sys/sparc64/sparc64/pmap.c	(working copy)
@@ -1211,11 +1211,9 @@
 	 */
 	if (pm->pm_tsb == NULL) {
 		pm->pm_tsb = (struct tte *)kva_alloc(TSB_BSIZE);
-		if (pm->pm_tsb == NULL) {
-			PMAP_LOCK_DESTROY(pm);
+		if (pm->pm_tsb == NULL)
 			return (0);
 		}
-	}
 
 	/*
 	 * Allocate an object for it.
-------------- next part --------------
Index: sys/amd64/include/pmap.h
===================================================================
--- sys/amd64/include/pmap.h	(revision 270020)
+++ sys/amd64/include/pmap.h	(working copy)
@@ -326,7 +326,6 @@
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_ASSERT(pmap, type) \
 				mtx_assert(&(pmap)->pm_mtx, (type))
-#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap", \
 				    NULL, MTX_DEF | MTX_DUPOK)
 #define	PMAP_LOCKED(pmap)	mtx_owned(&(pmap)->pm_mtx)
Index: sys/arm/include/pmap.h
===================================================================
--- sys/arm/include/pmap.h	(revision 270020)
+++ sys/arm/include/pmap.h	(working copy)
@@ -176,7 +176,6 @@
 #define	PMAP_ASSERT_LOCKED(pmap) \
 				mtx_assert(&(pmap)->pm_mtx, MA_OWNED)
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
-#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap", \
 				    NULL, MTX_DEF | MTX_DUPOK)
 #define	PMAP_OWNED(pmap)	mtx_owned(&(pmap)->pm_mtx)
Index: sys/i386/i386/pmap.c
===================================================================
--- sys/i386/i386/pmap.c	(revision 270020)
+++ sys/i386/i386/pmap.c	(working copy)
@@ -1755,10 +1755,8 @@
 	 */
 	if (pmap->pm_pdir == NULL) {
 		pmap->pm_pdir = (pd_entry_t *)kva_alloc(NBPTD);
-		if (pmap->pm_pdir == NULL) {
-			PMAP_LOCK_DESTROY(pmap);
+		if (pmap->pm_pdir == NULL)
 			return (0);
-		}
 #ifdef PAE
 		pmap->pm_pdpt = uma_zalloc(pdptzone, M_WAITOK | M_ZERO);
 		KASSERT(((vm_offset_t)pmap->pm_pdpt &
Index: sys/i386/include/pmap.h
===================================================================
--- sys/i386/include/pmap.h	(revision 270020)
+++ sys/i386/include/pmap.h	(working copy)
@@ -386,7 +386,6 @@
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_ASSERT(pmap, type) \
 				mtx_assert(&(pmap)->pm_mtx, (type))
-#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap", \
 				    NULL, MTX_DEF | MTX_DUPOK)
 #define	PMAP_LOCKED(pmap)	mtx_owned(&(pmap)->pm_mtx)
Index: sys/i386/xen/pmap.c
===================================================================
--- sys/i386/xen/pmap.c	(revision 270020)
+++ sys/i386/xen/pmap.c	(working copy)
@@ -1459,7 +1459,6 @@
 	if (pmap->pm_pdir == NULL) {
 		pmap->pm_pdir = (pd_entry_t *)kva_alloc(NBPTD);
 		if (pmap->pm_pdir == NULL) {
-			PMAP_LOCK_DESTROY(pmap);
 #ifdef HAMFISTED_LOCKING
 			mtx_unlock(&createdelete_lock);
 #endif
Index: sys/mips/include/pmap.h
===================================================================
--- sys/mips/include/pmap.h	(revision 270020)
+++ sys/mips/include/pmap.h	(working copy)
@@ -106,7 +106,6 @@
 
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_ASSERT(pmap, type)	mtx_assert(&(pmap)->pm_mtx, (type))
-#define	PMAP_LOCK_DESTROY(pmap) mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap", \
 				    NULL, MTX_DEF)
 #define	PMAP_LOCKED(pmap)	mtx_owned(&(pmap)->pm_mtx)
Index: sys/powerpc/include/pmap.h
===================================================================
--- sys/powerpc/include/pmap.h	(revision 270020)
+++ sys/powerpc/include/pmap.h	(working copy)
@@ -213,7 +213,6 @@
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_ASSERT(pmap, type) \
 				mtx_assert(&(pmap)->pm_mtx, (type))
-#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, \
 				    (pmap == kernel_pmap) ? "kernelpmap" : \
 				    "pmap", NULL, MTX_DEF)
Index: sys/sparc64/include/pmap.h
===================================================================
--- sys/sparc64/include/pmap.h	(revision 270020)
+++ sys/sparc64/include/pmap.h	(working copy)
@@ -70,7 +70,6 @@
 #define	PMAP_LOCK(pmap)		mtx_lock(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_ASSERT(pmap, type)					\
 				mtx_assert(&(pmap)->pm_mtx, (type))
-#define	PMAP_LOCK_DESTROY(pmap)	mtx_destroy(&(pmap)->pm_mtx)
 #define	PMAP_LOCK_INIT(pmap)	mtx_init(&(pmap)->pm_mtx, "pmap",	\
 				    NULL, MTX_DEF | MTX_DUPOK)
 #define	PMAP_LOCKED(pmap)	mtx_owned(&(pmap)->pm_mtx)
Index: sys/sparc64/sparc64/pmap.c
===================================================================
--- sys/sparc64/sparc64/pmap.c	(revision 270020)
+++ sys/sparc64/sparc64/pmap.c	(working copy)
@@ -1211,11 +1211,9 @@
 	 */
 	if (pm->pm_tsb == NULL) {
 		pm->pm_tsb = (struct tte *)kva_alloc(TSB_BSIZE);
-		if (pm->pm_tsb == NULL) {
-			PMAP_LOCK_DESTROY(pm);
+		if (pm->pm_tsb == NULL)
 			return (0);
 		}
-	}
 
 	/*
 	 * Allocate an object for it.


More information about the freebsd-arch mailing list