Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/sys Avoid prepending a timestamp to lock debug outputs o...
details: https://anonhg.NetBSD.org/src/rev/a4b561633f3f
branches: trunk
changeset: 998949:a4b561633f3f
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu May 09 05:00:31 2019 +0000
description:
Avoid prepending a timestamp to lock debug outputs on ddb
Lock printer functions (lockops_t#lo_dump) use printf_nolog to print, but
printf_nolog now prepends a timestamp which is unnecessary for ddb:
db{0}> show all locks/t
[Locks tracked through LWPs]
Locks held by an LWP (iperf):
Lock 0 (initialized at soinit)
lock address : 0xffffedeb84b06080 type : sleep/adaptive
initialized : 0xffffffff806d8c3f
shared holds : 0 exclusive: 1
shares wanted: 0 exclusive: 11
current cpu : 0 last held: 1
current lwp : 0xffffedeb849ff040 last held: 0xffffedeb7dfdb240
last locked* : 0xffffffff806d8335 unlocked : 0xffffffff806d8385
[ 79103.0868574] owner field : 0xffffedeb7dfdb240 wait/spin: 1/0
Fix it by passing a printer function to lo_dump functions, i.e., make the
functions use db_printf on ddb.
diffstat:
sys/external/bsd/drm2/linux/linux_ww_mutex.c | 34 ++++++++++++++--------------
sys/kern/kern_lock.c | 10 ++++----
sys/kern/kern_mutex.c | 10 ++++----
sys/kern/kern_rwlock.c | 10 ++++----
sys/kern/subr_lockdebug.c | 8 +++---
sys/sys/lockdebug.h | 6 +++-
6 files changed, 40 insertions(+), 38 deletions(-)
diffs (258 lines):
diff -r 3c04cffecfb3 -r a4b561633f3f sys/external/bsd/drm2/linux/linux_ww_mutex.c
--- a/sys/external/bsd/drm2/linux/linux_ww_mutex.c Thu May 09 04:53:52 2019 +0000
+++ b/sys/external/bsd/drm2/linux/linux_ww_mutex.c Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: linux_ww_mutex.c,v 1.6 2019/04/16 10:00:04 mrg Exp $ */
+/* $NetBSD: linux_ww_mutex.c,v 1.7 2019/05/09 05:00:31 ozaki-r Exp $ */
/*-
* Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.6 2019/04/16 10:00:04 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_ww_mutex.c,v 1.7 2019/05/09 05:00:31 ozaki-r Exp $");
#include <sys/types.h>
#include <sys/atomic.h>
@@ -123,40 +123,40 @@
#ifdef LOCKDEBUG
static void
-ww_dump(const volatile void *cookie)
+ww_dump(const volatile void *cookie, lockop_printer_t pr)
{
const volatile struct ww_mutex *mutex = cookie;
- printf_nolog("%-13s: ", "state");
+ pr("%-13s: ", "state");
switch (mutex->wwm_state) {
case WW_UNLOCKED:
- printf_nolog("unlocked\n");
+ pr("unlocked\n");
break;
case WW_OWNED:
- printf_nolog("owned by lwp\n");
- printf_nolog("%-13s: %p\n", "owner", mutex->wwm_u.owner);
- printf_nolog("%-13s: %s\n", "waiters",
+ pr("owned by lwp\n");
+ pr("%-13s: %p\n", "owner", mutex->wwm_u.owner);
+ pr("%-13s: %s\n", "waiters",
cv_has_waiters((void *)(intptr_t)&mutex->wwm_cv)
? "yes" : "no");
break;
case WW_CTX:
- printf_nolog("owned via ctx\n");
- printf_nolog("%-13s: %p\n", "context", mutex->wwm_u.ctx);
- printf_nolog("%-13s: %p\n", "lwp",
+ pr("owned via ctx\n");
+ pr("%-13s: %p\n", "context", mutex->wwm_u.ctx);
+ pr("%-13s: %p\n", "lwp",
mutex->wwm_u.ctx->wwx_owner);
- printf_nolog("%-13s: %s\n", "waiters",
+ pr("%-13s: %s\n", "waiters",
cv_has_waiters((void *)(intptr_t)&mutex->wwm_cv)
? "yes" : "no");
break;
case WW_WANTOWN:
- printf_nolog("owned via ctx\n");
- printf_nolog("%-13s: %p\n", "context", mutex->wwm_u.ctx);
- printf_nolog("%-13s: %p\n", "lwp",
+ pr("owned via ctx\n");
+ pr("%-13s: %p\n", "context", mutex->wwm_u.ctx);
+ pr("%-13s: %p\n", "lwp",
mutex->wwm_u.ctx->wwx_owner);
- printf_nolog("%-13s: %s\n", "waiters", "yes (noctx)");
+ pr("%-13s: %s\n", "waiters", "yes (noctx)");
break;
default:
- printf_nolog("unknown\n");
+ pr("unknown\n");
break;
}
}
diff -r 3c04cffecfb3 -r a4b561633f3f sys/kern/kern_lock.c
--- a/sys/kern/kern_lock.c Thu May 09 04:53:52 2019 +0000
+++ b/sys/kern/kern_lock.c Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_lock.c,v 1.162 2019/05/09 04:53:52 ozaki-r Exp $ */
+/* $NetBSD: kern_lock.c,v 1.163 2019/05/09 05:00:31 ozaki-r Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.162 2019/05/09 04:53:52 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lock.c,v 1.163 2019/05/09 05:00:31 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/proc.h>
@@ -117,7 +117,7 @@
#define _KERNEL_LOCK_ASSERT(cond) /* nothing */
#endif
-static void _kernel_lock_dump(const volatile void *);
+static void _kernel_lock_dump(const volatile void *, lockop_printer_t);
lockops_t _kernel_lock_ops = {
.lo_name = "Kernel lock",
@@ -142,13 +142,13 @@
* Print debugging information about the kernel lock.
*/
static void
-_kernel_lock_dump(const volatile void *junk)
+_kernel_lock_dump(const volatile void *junk, lockop_printer_t pr)
{
struct cpu_info *ci = curcpu();
(void)junk;
- printf_nolog("curcpu holds : %18d wanted by: %#018lx\n",
+ pr("curcpu holds : %18d wanted by: %#018lx\n",
ci->ci_biglock_count, (long)ci->ci_biglock_wanted);
}
diff -r 3c04cffecfb3 -r a4b561633f3f sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c Thu May 09 04:53:52 2019 +0000
+++ b/sys/kern/kern_mutex.c Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_mutex.c,v 1.78 2019/05/09 04:52:59 ozaki-r Exp $ */
+/* $NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -40,7 +40,7 @@
#define __MUTEX_PRIVATE
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.78 2019/05/09 04:52:59 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.79 2019/05/09 05:00:31 ozaki-r Exp $");
#include <sys/param.h>
#include <sys/atomic.h>
@@ -271,7 +271,7 @@
static void mutex_abort(const char *, size_t, const kmutex_t *,
const char *);
-static void mutex_dump(const volatile void *);
+static void mutex_dump(const volatile void *, lockop_printer_t);
lockops_t mutex_spin_lockops = {
.lo_name = "Mutex",
@@ -299,11 +299,11 @@
* Dump the contents of a mutex structure.
*/
static void
-mutex_dump(const volatile void *cookie)
+mutex_dump(const volatile void *cookie, lockop_printer_t pr)
{
const volatile kmutex_t *mtx = cookie;
- printf_nolog("owner field : %#018lx wait/spin: %16d/%d\n",
+ pr("owner field : %#018lx wait/spin: %16d/%d\n",
(long)MUTEX_OWNER(mtx->mtx_owner), MUTEX_HAS_WAITERS(mtx),
MUTEX_SPIN_P(mtx));
}
diff -r 3c04cffecfb3 -r a4b561633f3f sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c Thu May 09 04:53:52 2019 +0000
+++ b/sys/kern/kern_rwlock.c Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_rwlock.c,v 1.53 2019/04/17 02:29:43 ozaki-r Exp $ */
+/* $NetBSD: kern_rwlock.c,v 1.54 2019/05/09 05:00:31 ozaki-r Exp $ */
/*-
* Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.53 2019/04/17 02:29:43 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.54 2019/05/09 05:00:31 ozaki-r Exp $");
#define __RWLOCK_PRIVATE
@@ -113,7 +113,7 @@
#endif /* defined(LOCKDEBUG) */
static void rw_abort(const char *, size_t, krwlock_t *, const char *);
-static void rw_dump(const volatile void *);
+static void rw_dump(const volatile void *, lockop_printer_t);
static lwp_t *rw_owner(wchan_t);
static inline uintptr_t
@@ -168,11 +168,11 @@
* Dump the contents of a rwlock structure.
*/
static void
-rw_dump(const volatile void *cookie)
+rw_dump(const volatile void *cookie, lockop_printer_t pr)
{
const volatile krwlock_t *rw = cookie;
- printf_nolog("owner/count : %#018lx flags : %#018x\n",
+ pr("owner/count : %#018lx flags : %#018x\n",
(long)RW_OWNER(rw), (int)RW_FLAGS(rw));
}
diff -r 3c04cffecfb3 -r a4b561633f3f sys/kern/subr_lockdebug.c
--- a/sys/kern/subr_lockdebug.c Thu May 09 04:53:52 2019 +0000
+++ b/sys/kern/subr_lockdebug.c Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_lockdebug.c,v 1.69 2018/11/03 15:20:03 christos Exp $ */
+/* $NetBSD: subr_lockdebug.c,v 1.70 2019/05/09 05:00:31 ozaki-r 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.69 2018/11/03 15:20:03 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.70 2019/05/09 05:00:31 ozaki-r Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -768,7 +768,7 @@
}
if (ld->ld_lockops->lo_dump != NULL)
- (*ld->ld_lockops->lo_dump)(ld->ld_lock);
+ (*ld->ld_lockops->lo_dump)(ld->ld_lock, pr);
if (sleeper) {
(*pr)("\n");
@@ -1037,7 +1037,7 @@
"current lwp : %#018lx\n",
ops->lo_name, func, line, msg, (long)lock,
(int)cpu_index(curcpu()), (long)curlwp);
- (*ops->lo_dump)(lock);
+ (*ops->lo_dump)(lock, printf_nolog);
printf_nolog("\n");
panic("lock error: %s: %s,%zu: %s: lock %p cpu %d lwp %p",
diff -r 3c04cffecfb3 -r a4b561633f3f sys/sys/lockdebug.h
--- a/sys/sys/lockdebug.h Thu May 09 04:53:52 2019 +0000
+++ b/sys/sys/lockdebug.h Thu May 09 05:00:31 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: lockdebug.h,v 1.20 2018/08/12 22:05:29 mrg Exp $ */
+/* $NetBSD: lockdebug.h,v 1.21 2019/05/09 05:00:31 ozaki-r Exp $ */
/*-
* Copyright (c) 2006, 2007, 2008 The NetBSD Foundation, Inc.
@@ -44,10 +44,12 @@
#define LOCKOPS_SPIN 1
#define LOCKOPS_CV 2
+typedef void (*lockop_printer_t)(const char *, ...) __printflike(1, 2);
+
typedef struct lockops {
const char *lo_name;
int lo_type;
- void (*lo_dump)(const volatile void *);
+ void (*lo_dump)(const volatile void *, lockop_printer_t);
} lockops_t;
#define LOCKDEBUG_ABORT(f, ln, l, o, m) \
Home |
Main Index |
Thread Index |
Old Index