Module Name:    src
Committed By:   martin
Date:           Sun Sep 23 17:28:25 UTC 2018

Modified Files:
        src/sys/ddb [netbsd-8]: db_command.c
        src/sys/kern [netbsd-8]: subr_lockdebug.c

Log Message:
Pull up following revision(s) (requested by mrg in ticket #1024):

        sys/ddb/db_command.c: revision 1.157
        sys/ddb/db_command.c: revision 1.158
        sys/kern/subr_lockdebug.c: revision 1.67

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.

call spl0() before cpu_reboot(), so that there's a chance that:
- interrupts can work afterwards
- this also means if IO stalls, serial break might work again.

this mimics how reboot(2) ends up calling cpu_reboot().


To generate a diff of this commit:
cvs rdiff -u -r1.148.8.3 -r1.148.8.4 src/sys/ddb/db_command.c
cvs rdiff -u -r1.57.2.2 -r1.57.2.3 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.148.8.3 src/sys/ddb/db_command.c:1.148.8.4
--- src/sys/ddb/db_command.c:1.148.8.3	Fri Sep  7 12:34:18 2018
+++ src/sys/ddb/db_command.c	Sun Sep 23 17:28:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: db_command.c,v 1.148.8.3 2018/09/07 12:34:18 martin Exp $	*/
+/*	$NetBSD: db_command.c,v 1.148.8.4 2018/09/23 17:28:25 martin 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.148.8.3 2018/09/07 12:34:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: db_command.c,v 1.148.8.4 2018/09/23 17:28:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_aio.h"
@@ -1352,10 +1352,10 @@ 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";
+	/* Make it possible to break into the debugger again */
+	spl0();
 	cpu_reboot((int)bootflags, NULL);
 #else	/* _KERNEL */
 	db_printf("This command can only be used in-kernel.\n");

Index: src/sys/kern/subr_lockdebug.c
diff -u src/sys/kern/subr_lockdebug.c:1.57.2.2 src/sys/kern/subr_lockdebug.c:1.57.2.3
--- src/sys/kern/subr_lockdebug.c:1.57.2.2	Fri Sep  7 12:34:18 2018
+++ src/sys/kern/subr_lockdebug.c	Sun Sep 23 17:28:25 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_lockdebug.c,v 1.57.2.2 2018/09/07 12:34:18 martin Exp $	*/
+/*	$NetBSD: subr_lockdebug.c,v 1.57.2.3 2018/09/23 17:28:25 martin 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.57.2.2 2018/09/07 12:34:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.57.2.3 2018/09/23 17:28:25 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1012,20 +1012,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