Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Catch a leaked hold of kernel_lock sooner with DIAGNOSTI...
details: https://anonhg.NetBSD.org/src/rev/344558d5261c
branches: trunk
changeset: 1006650:344558d5261c
user: ad <ad%NetBSD.org@localhost>
date: Wed Jan 22 12:23:04 2020 +0000
description:
Catch a leaked hold of kernel_lock sooner with DIAGNOSTIC and make the
message a bit more informative.
diffstat:
sys/kern/kern_exit.c | 5 +++--
sys/kern/kern_lwp.c | 11 ++++++-----
sys/sys/userret.h | 7 ++++---
3 files changed, 13 insertions(+), 10 deletions(-)
diffs (92 lines):
diff -r c66646b9e611 -r 344558d5261c sys/kern/kern_exit.c
--- a/sys/kern/kern_exit.c Wed Jan 22 11:38:54 2020 +0000
+++ b/sys/kern/kern_exit.c Wed Jan 22 12:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_exit.c,v 1.279 2020/01/08 17:38:42 ad Exp $ */
+/* $NetBSD: kern_exit.c,v 1.280 2020/01/22 12:23:04 ad Exp $ */
/*-
* Copyright (c) 1998, 1999, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.279 2020/01/08 17:38:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.280 2020/01/22 12:23:04 ad Exp $");
#include "opt_ktrace.h"
#include "opt_dtrace.h"
@@ -206,6 +206,7 @@
/* 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");
KASSERT(mutex_owned(p->p_lock));
KASSERT(p->p_vmspace != NULL);
diff -r c66646b9e611 -r 344558d5261c sys/kern/kern_lwp.c
--- a/sys/kern/kern_lwp.c Wed Jan 22 11:38:54 2020 +0000
+++ b/sys/kern/kern_lwp.c Wed Jan 22 12:23:04 2020 +0000
@@ -1,7 +1,8 @@
-/* $NetBSD: kern_lwp.c,v 1.219 2020/01/12 13:15:08 ad Exp $ */
+/* $NetBSD: kern_lwp.c,v 1.220 2020/01/22 12:23:04 ad Exp $ */
/*-
- * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
+ * The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -209,7 +210,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.219 2020/01/12 13:15:08 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.220 2020/01/22 12:23:04 ad Exp $");
#include "opt_ddb.h"
#include "opt_lockdebug.h"
@@ -1063,8 +1064,9 @@
SDT_PROBE(proc, kernel, , lwp__exit, l, 0, 0, 0, 0);
- /* Verify that we hold no locks */
+ /* Verify that we hold no locks; for DIAGNOSTIC check kernel_lock. */
LOCKDEBUG_BARRIER(NULL, 0);
+ KASSERTMSG(curcpu()->ci_biglock_count == 0, "kernel_lock leaked");
/*
* If we are the last live LWP in a process, we need to exit the
@@ -1080,7 +1082,6 @@
if (p->p_nlwps - p->p_nzlwps == 1) {
KASSERT(current == true);
KASSERT(p != &proc0);
- /* XXXSMP kernel_lock not held */
exit1(l, 0, 0);
/* NOTREACHED */
}
diff -r c66646b9e611 -r 344558d5261c sys/sys/userret.h
--- a/sys/sys/userret.h Wed Jan 22 11:38:54 2020 +0000
+++ b/sys/sys/userret.h Wed Jan 22 12:23:04 2020 +0000
@@ -1,7 +1,8 @@
-/* $NetBSD: userret.h,v 1.31 2019/11/30 17:49:03 ad Exp $ */
+/* $NetBSD: userret.h,v 1.32 2020/01/22 12:23:04 ad Exp $ */
/*-
- * Copyright (c) 1998, 2000, 2003, 2006, 2008, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 1998, 2000, 2003, 2006, 2008, 2019, 2020
+ * The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
@@ -84,8 +85,8 @@
KPREEMPT_DISABLE(l);
ci = l->l_cpu;
+ KASSERTMSG(ci->ci_biglock_count == 0, "kernel_lock leaked");
KASSERT(l->l_blcnt == 0);
- KASSERT(ci->ci_biglock_count == 0);
if (__predict_false(ci->ci_want_resched)) {
preempt();
ci = l->l_cpu;
Home |
Main Index |
Thread Index |
Old Index