Sun Mar 8 15:05:18 2020 UTC ()
Kill off kernel_lock_plug_leak(), and go back to dropping kernel_lock in
exit1(), since there seems little hope of finding the leaking code any
time soon.  Can still be caught with LOCKDEBUG.


(ad)
diff -r1.284 -r1.285 src/sys/kern/kern_exit.c
diff -r1.169 -r1.170 src/sys/kern/kern_lock.c
diff -r1.61 -r1.62 src/sys/kern/kern_softint.c
diff -r1.88 -r1.89 src/sys/sys/lock.h

cvs diff -r1.284 -r1.285 src/sys/kern/kern_exit.c (expand / switch to context diff)
--- src/sys/kern/kern_exit.c 2020/02/22 21:07:46 1.284
+++ src/sys/kern/kern_exit.c 2020/03/08 15:05:18 1.285
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.284 2020/02/22 21:07:46 ad Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.284 2020/02/22 21:07:46 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -206,12 +206,12 @@
 
 	p = l->l_proc;
 
-	/* XXX Temporary. */
-	kernel_lock_plug_leak();
-
 	/* Verify that we hold no locks other than p->p_lock. */
 	LOCKDEBUG_BARRIER(p->p_lock, 0);
-	KASSERTMSG(curcpu()->ci_biglock_count == 0, "kernel_lock leaked");
+
+	/* XXX Temporary: something is leaking kernel_lock. */
+	KERNEL_UNLOCK_ALL(l, NULL);
+
 	KASSERT(mutex_owned(p->p_lock));
 	KASSERT(p->p_vmspace != NULL);
 

cvs diff -r1.169 -r1.170 src/sys/kern/kern_lock.c (expand / switch to context diff)
--- src/sys/kern/kern_lock.c 2020/02/10 22:11:09 1.169
+++ src/sys/kern/kern_lock.c 2020/03/08 15:05:18 1.170
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $	*/
+/*	$NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009, 2020 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.169 2020/02/10 22:11:09 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.170 2020/03/08 15:05:18 ad Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_lockdebug.h"
@@ -342,24 +342,4 @@
 _kernel_locked_p(void)
 {
 	return __SIMPLELOCK_LOCKED_P(kernel_lock);
-}
-
-void
-kernel_lock_plug_leak(void)
-{
-#ifndef LOCKDEBUG
-# ifdef DIAGNOSTIC
-	int biglocks = 0;
-	KERNEL_UNLOCK_ALL(curlwp, &biglocks);
-	if (biglocks != 0) {
-		const char *sym = "(unknown)";
-		ksyms_getname(NULL, &sym, (vaddr_t)curlwp->l_ld_wanted,
-		    KSYMS_CLOSEST|KSYMS_PROC|KSYMS_ANY);
-		printf("kernel_lock leak detected. last acquired: %s / %p\n",
-		    sym, curlwp->l_ld_wanted);
-	}
-# else
-	KERNEL_UNLOCK_ALL(curlwp, NULL);
-# endif
-#endif
 }

cvs diff -r1.61 -r1.62 src/sys/kern/kern_softint.c (expand / switch to context diff)
--- src/sys/kern/kern_softint.c 2020/02/17 21:44:42 1.61
+++ src/sys/kern/kern_softint.c 2020/03/08 15:05:18 1.62
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.61 2020/02/17 21:44:42 ad Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.61 2020/02/17 21:44:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/proc.h>
@@ -889,9 +889,6 @@
 		updatertime(l, &now);
 		l->l_pflag &= ~LP_TIMEINTR;
 	}
-
-	/* XXX temporary */
-	kernel_lock_plug_leak();
 
 	/*
 	 * If we blocked while handling the interrupt, the pinned LWP is

cvs diff -r1.88 -r1.89 src/sys/sys/lock.h (expand / switch to context diff)
--- src/sys/sys/lock.h 2020/01/27 21:05:43 1.88
+++ src/sys/sys/lock.h 2020/03/08 15:05:18 1.89
@@ -1,4 +1,4 @@
-/*	$NetBSD: lock.h,v 1.88 2020/01/27 21:05:43 ad Exp $	*/
+/*	$NetBSD: lock.h,v 1.89 2020/03/08 15:05:18 ad Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2006, 2007 The NetBSD Foundation, Inc.
@@ -108,8 +108,6 @@
 #endif
 
 extern __cpu_simple_lock_t kernel_lock[];
-
-void	kernel_lock_plug_leak(void);
 
 #endif /* _KERNEL */