Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Improve debugging functions
details: https://anonhg.NetBSD.org/src/rev/93cb15288ef8
branches: trunk
changeset: 358142:93cb15288ef8
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Thu Dec 14 05:45:55 2017 +0000
description:
Improve debugging functions
- Make psref_check_duplication check just if a given psref is on the list
- It checked both psref and target
- Suggested by riastradh@ some time ago
- Add psref_check_existence that checks a releasing psref is surely on the list
diffstat:
sys/kern/subr_psref.c | 46 ++++++++++++++++++++++++++++++++++------------
1 files changed, 34 insertions(+), 12 deletions(-)
diffs (80 lines):
diff -r 1f20798b46c5 -r 93cb15288ef8 sys/kern/subr_psref.c
--- a/sys/kern/subr_psref.c Thu Dec 14 05:43:14 2017 +0000
+++ b/sys/kern/subr_psref.c Thu Dec 14 05:45:55 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_psref.c,v 1.8 2017/12/11 02:33:17 knakahara Exp $ */
+/* $NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $ */
/*-
* Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -64,7 +64,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.8 2017/12/11 02:33:17 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.9 2017/12/14 05:45:55 ozaki-r Exp $");
#include <sys/types.h>
#include <sys/condvar.h>
@@ -187,22 +187,40 @@
}
#ifdef DEBUG
+static bool
+psref_exist(struct psref_cpu *pcpu, struct psref *psref)
+{
+ struct psref *_psref;
+
+ SLIST_FOREACH(_psref, &pcpu->pcpu_head, psref_entry) {
+ if (_psref == psref)
+ return true;
+ }
+ return false;
+}
+
static void
psref_check_duplication(struct psref_cpu *pcpu, struct psref *psref,
const struct psref_target *target)
{
bool found = false;
- struct psref *_psref;
+
+ found = psref_exist(pcpu, psref);
+ if (found) {
+ panic("The psref is already in the list (acquiring twice?): "
+ "psref=%p target=%p", psref, target);
+ }
+}
- SLIST_FOREACH(_psref, &pcpu->pcpu_head, psref_entry) {
- if (_psref == psref &&
- _psref->psref_target == target) {
- found = true;
- break;
- }
- }
- if (found) {
- panic("trying to acquire a target twice with the same psref: "
+static void
+psref_check_existence(struct psref_cpu *pcpu, struct psref *psref,
+ const struct psref_target *target)
+{
+ bool found = false;
+
+ found = psref_exist(pcpu, psref);
+ if (!found) {
+ panic("The psref isn't in the list (releasing unused psref?): "
"psref=%p target=%p", psref, target);
}
}
@@ -304,6 +322,10 @@
*/
s = splraiseipl(class->prc_iplcookie);
pcpu = percpu_getref(class->prc_percpu);
+#ifdef DEBUG
+ /* Sanity-check if the target is surely acquired before. */
+ psref_check_existence(pcpu, psref, target);
+#endif
SLIST_REMOVE(&pcpu->pcpu_head, psref, psref, psref_entry);
percpu_putref(class->prc_percpu);
splx(s);
Home |
Main Index |
Thread Index |
Old Index