Module Name: src
Committed By: riastradh
Date: Fri Aug 12 16:16:12 UTC 2022
Modified Files:
src/sys/kern: subr_autoconf.c
Log Message:
autoconf(9): Provide diagnostics for config_detach_* misuse.
To generate a diff of this commit:
cvs rdiff -u -r1.301 -r1.302 src/sys/kern/subr_autoconf.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/kern/subr_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.301 src/sys/kern/subr_autoconf.c:1.302
--- src/sys/kern/subr_autoconf.c:1.301 Mon Mar 28 12:38:59 2022
+++ src/sys/kern/subr_autoconf.c Fri Aug 12 16:16:12 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.301 2022/03/28 12:38:59 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.302 2022/08/12 16:16:12 riastradh Exp $ */
/*
* Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.301 2022/03/28 12:38:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.302 2022/08/12 16:16:12 riastradh Exp $");
#ifdef _KERNEL_OPT
#include "opt_ddb.h"
@@ -1919,6 +1919,7 @@ config_dump_garbage(struct devicelist *g
static int
config_detach_enter(device_t dev)
{
+ struct lwp *l __diagused;
int error = 0;
mutex_enter(&config_misc_lock);
@@ -1947,8 +1948,12 @@ config_detach_enter(device_t dev)
* running. Claim the device for detaching. This will cause
* all new attempts to acquire references to block.
*/
- KASSERT(dev->dv_attaching == NULL);
- KASSERT(dev->dv_detaching == NULL);
+ KASSERTMSG((l = dev->dv_attaching) == NULL,
+ "lwp %ld [%s] @ %p attaching",
+ (long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
+ KASSERTMSG((l = dev->dv_detaching) == NULL,
+ "lwp %ld [%s] @ %p detaching",
+ (long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
dev->dv_detaching = curlwp;
out: mutex_exit(&config_misc_lock);
@@ -1958,9 +1963,12 @@ out: mutex_exit(&config_misc_lock);
static void
config_detach_exit(device_t dev)
{
+ struct lwp *l __diagused;
mutex_enter(&config_misc_lock);
- KASSERT(dev->dv_detaching == curlwp);
+ KASSERTMSG((l = dev->dv_detaching) == curlwp,
+ "lwp %ld [%s] @ %p detaching",
+ (long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
dev->dv_detaching = NULL;
cv_broadcast(&config_misc_cv);
mutex_exit(&config_misc_lock);
@@ -2171,9 +2179,12 @@ out:
void
config_detach_commit(device_t dev)
{
+ struct lwp *l __diagused;
mutex_enter(&config_misc_lock);
- KASSERT(dev->dv_detaching == curlwp);
+ KASSERTMSG((l = dev->dv_detaching) == curlwp,
+ "lwp %ld [%s] @ %p detaching",
+ (long)l->l_lid, (l->l_name ? l->l_name : l->l_proc->p_comm), l);
dev->dv_detached = true;
cv_broadcast(&config_misc_cv);
mutex_exit(&config_misc_lock);