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.
This commit is contained in:
parent
1180247a6a
commit
00cd510af4
|
@ -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 @@ ww_acquire_fini(struct ww_acquire_ctx *ctx)
|
|||
|
||||
#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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 @@ do { \
|
|||
#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 @@ CTASSERT(CACHE_LINE_SIZE >= sizeof(__cpu_simple_lock_t));
|
|||
* 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ __strong_alias(mutex_spin_exit,mutex_vector_exit);
|
|||
|
||||
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 @@ syncobj_t mutex_syncobj = {
|
|||
* 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));
|
||||
}
|
||||
|
|
|
@ -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 @@ do { \
|
|||
#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 @@ syncobj_t rw_syncobj = {
|
|||
* 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));
|
||||
}
|
||||
|
||||
|
|
|
@ -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 @@ lockdebug_dump(lockdebug_t *ld, void (*pr)(const char *, ...)
|
|||
}
|
||||
|
||||
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 @@ lockdebug_abort(const char *func, size_t line, const volatile void *lock,
|
|||
"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",
|
||||
|
|
|
@ -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) \
|
||||
|
|
Loading…
Reference in New Issue