Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern KERNEL_LOCK(9): Send an IPI to print holder's stack...
details: https://anonhg.NetBSD.org/src/rev/2dce4a344113
branches: trunk
changeset: 369406:2dce4a344113
user: riastradh <riastradh%NetBSD.org@localhost>
date: Tue Aug 16 00:26:39 2022 +0000
description:
KERNEL_LOCK(9): Send an IPI to print holder's stack trace on spinout.
diffstat:
sys/kern/kern_lock.c | 30 ++++++++++++++++++++++++++++--
1 files changed, 28 insertions(+), 2 deletions(-)
diffs (72 lines):
diff -r 230826f1b7a4 -r 2dce4a344113 sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c Mon Aug 15 18:06:04 2022 +0000
+++ b/sys/kern/kern_lock.c Tue Aug 16 00:26:39 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lock.c,v 1.173 2021/10/31 16:26:26 skrll Exp $ */
+/* $NetBSD: kern_lock.c,v 1.174 2022/08/16 00:26:39 riastradh 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.173 2021/10/31 16:26:26 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.174 2022/08/16 00:26:39 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_lockdebug.h"
@@ -134,6 +134,22 @@
.lo_dump = _kernel_lock_dump,
};
+#ifdef LOCKDEBUG
+
+#include <ddb/ddb.h>
+
+static void
+kernel_lock_trace_ipi(void *cookie)
+{
+
+ printf("%s[%d %s]: hogging kernel lock\n", cpu_name(curcpu()),
+ curlwp->l_lid,
+ curlwp->l_name ? curlwp->l_name : curproc->p_comm);
+ db_stacktrace();
+}
+
+#endif
+
/*
* Initialize the kernel lock.
*/
@@ -177,6 +193,7 @@
LOCKSTAT_FLAG(lsflag);
struct lwp *owant;
#ifdef LOCKDEBUG
+ static struct cpu_info *kernel_lock_holder;
u_int spins = 0;
#endif
int s;
@@ -235,6 +252,11 @@
#ifdef LOCKDEBUG
if (SPINLOCK_SPINOUT(spins)) {
extern int start_init_exec;
+ ipi_msg_t msg = {
+ .func = kernel_lock_trace_ipi,
+ };
+ ipi_unicast(&msg, kernel_lock_holder);
+ ipi_wait(&msg);
if (start_init_exec)
_KERNEL_LOCK_ABORT("spinout");
}
@@ -278,6 +300,10 @@
#ifndef __HAVE_ATOMIC_AS_MEMBAR
membar_enter();
#endif
+
+#ifdef LOCKDEBUG
+ kernel_lock_holder = curcpu();
+#endif
}
/*
Home |
Main Index |
Thread Index |
Old Index