Module Name:    src
Committed By:   mrg
Date:           Thu Sep 13 01:55:16 UTC 2018

Modified Files:
        src/sys/ddb: db_command.c
        src/sys/kern: subr_lockdebug.c

Log Message:
always call lockdebug_dismiss() from DDB -- there are always some
minimal lockdebug checks in place, even without LOCKDEBUG.

adjust lockdebug_abort() to ignore problems after ld_panic is set
so that there's a chance of this working.

this fixes ddb 'reboot' on softiron od1000.


To generate a diff of this commit:
cvs rdiff -u -r1.156 -r1.157 src/sys/ddb/db_command.c
cvs rdiff -u -r1.66 -r1.67 src/sys/kern/subr_lockdebug.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/ddb/db_command.c
diff -u src/sys/ddb/db_command.c:1.156 src/sys/ddb/db_command.c:1.157
--- src/sys/ddb/db_command.c:1.156	Mon Aug 13 03:20:19 2018
+++ src/sys/ddb/db_command.c	Thu Sep 13 01:55:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_command.c,v 1.156 2018/08/13 03:20:19 mrg Exp $	*/
+/*	$NetBSD: db_command.c,v 1.157 2018/09/13 01:55:16 mrg Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002, 2009 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.156 2018/08/13 03:20:19 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.157 2018/09/13 01:55:16 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -1353,9 +1353,7 @@ db_reboot_cmd(db_expr_t addr, bool have_
 	 */
 	db_recover = 0;
 	/* Avoid all mutex errors */
-#ifdef LOCKDEBUG
 	lockdebug_dismiss();
-#endif
 	panicstr = "reboot forced via kernel debugger";
 	cpu_reboot((int)bootflags, NULL);
 #else	/* _KERNEL */

Index: src/sys/kern/subr_lockdebug.c
diff -u src/sys/kern/subr_lockdebug.c:1.66 src/sys/kern/subr_lockdebug.c:1.67
--- src/sys/kern/subr_lockdebug.c:1.66	Mon Sep  3 16:29:35 2018
+++ src/sys/kern/subr_lockdebug.c	Thu Sep 13 01:55:16 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_lockdebug.c,v 1.66 2018/09/03 16:29:35 riastradh Exp $	*/
+/*	$NetBSD: subr_lockdebug.c,v 1.67 2018/09/13 01:55:16 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.66 2018/09/03 16:29:35 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.67 2018/09/13 01:55:16 mrg Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1016,20 +1016,21 @@ lockdebug_abort(const char *func, size_t
 #endif	/* LOCKDEBUG */
 
 	/*
-	 * Complain first on the occurrance only.  Otherwise proceeed to
-	 * panic where we will `rendezvous' with other CPUs if the machine
-	 * is going down in flames.
+	 * Don't make the situation worse if the system is already going
+	 * down in flames.  Once a panic is triggered, lockdebug state
+	 * becomes stale and cannot be trusted.
 	 */
-	if (atomic_inc_uint_nv(&ld_panic) == 1) {
-		printf_nolog("%s error: %s,%zu: %s\n\n"
-		    "lock address : %#018lx\n"
-		    "current cpu  : %18d\n"
-		    "current lwp  : %#018lx\n",
-		    ops->lo_name, func, line, msg, (long)lock,
-		    (int)cpu_index(curcpu()), (long)curlwp);
-		(*ops->lo_dump)(lock);
-		printf_nolog("\n");
-	}
+	if (atomic_inc_uint_nv(&ld_panic) > 1)
+		return;
+
+	printf_nolog("%s error: %s,%zu: %s\n\n"
+	    "lock address : %#018lx\n"
+	    "current cpu  : %18d\n"
+	    "current lwp  : %#018lx\n",
+	    ops->lo_name, func, line, msg, (long)lock,
+	    (int)cpu_index(curcpu()), (long)curlwp);
+	(*ops->lo_dump)(lock);
+	printf_nolog("\n");
 
 	panic("lock error: %s: %s,%zu: %s: lock %p cpu %d lwp %p",
 	    ops->lo_name, func, line, msg, lock, cpu_index(curcpu()), curlwp);

Reply via email to