Port-arm archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pmap locks and ddb



Hello
while debugging a deadlock on evbarm, a "mach cpu 1" ddb command would hang.
I think I found the problem: ddb will end up calling pmap functions
(pmap_extract() to check if an address is valid), and this one ends
up calling pmap_acquire_pmap_lock(). But the lock may already be held by
the other CPU (especially if the pmap is pmap_kernel, as in this case
the lock is kernel_lock).
The attached patch avoid the lock completely when in ddb, and allows me to
switch CPUs in ddb. Does anyone see a problem with this ?

-- 
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
     NetBSD: 26 ans d'experience feront toujours la difference
--
? allwinner
? dts/lime2-can.dts
? dts/lime2-can.dts.b
? dts/lime2-chartplotter.dts
Index: arm32/pmap.c
===================================================================
RCS file: /cvsroot/src/sys/arch/arm/arm32/pmap.c,v
retrieving revision 1.371
diff -u -p -u -r1.371 pmap.c
--- arm32/pmap.c	28 Oct 2018 14:59:17 -0000	1.371
+++ arm32/pmap.c	19 Apr 2019 10:28:53 -0000
@@ -217,6 +217,10 @@
 
 #include <arm/locore.h>
 
+#ifdef DDB
+#include <arm/db_machdep.h>
+#endif
+
 __KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.371 2018/10/28 14:59:17 skrll Exp $");
 
 //#define PMAP_DEBUG
@@ -538,6 +542,11 @@ vaddr_t pmap_directlimit;
 static inline void
 pmap_acquire_pmap_lock(pmap_t pm)
 {
+#if defined(MULTIPROCESSOR) && defined(DDB)
+	if (db_onproc != NULL)
+		return;
+#endif
+	
 	if (pm == pmap_kernel()) {
 #ifdef MULTIPROCESSOR
 		KERNEL_LOCK(1, NULL);
@@ -550,6 +559,10 @@ pmap_acquire_pmap_lock(pmap_t pm)
 static inline void
 pmap_release_pmap_lock(pmap_t pm)
 {
+#if defined(MULTIPROCESSOR) && defined(DDB)
+	if (db_onproc != NULL)
+		return;
+#endif
 	if (pm == pmap_kernel()) {
 #ifdef MULTIPROCESSOR
 		KERNEL_UNLOCK_ONE(NULL);


Home | Main Index | Thread Index | Old Index