Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Fix an assertion in _psref_held
details: https://anonhg.NetBSD.org/src/rev/d5ce8c5465b7
branches: trunk
changeset: 348599:d5ce8c5465b7
user: ozaki-r <ozaki-r%NetBSD.org@localhost>
date: Fri Oct 28 07:27:52 2016 +0000
description:
Fix an assertion in _psref_held
The assertion, psref->psref_lwp == curlwp, is valid only if the target
is held by the caller.
Reviewed by riastradh@
diffstat:
sys/kern/subr_psref.c | 31 ++++++++++++++++++++-----------
1 files changed, 20 insertions(+), 11 deletions(-)
diffs (56 lines):
diff -r af6da679a333 -r d5ce8c5465b7 sys/kern/subr_psref.c
--- a/sys/kern/subr_psref.c Fri Oct 28 07:26:41 2016 +0000
+++ b/sys/kern/subr_psref.c Fri Oct 28 07:27:52 2016 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_psref.c,v 1.4 2016/04/13 08:31:00 riastradh Exp $ */
+/* $NetBSD: subr_psref.c,v 1.5 2016/10/28 07:27:52 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.4 2016/04/13 08:31:00 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_psref.c,v 1.5 2016/10/28 07:27:52 ozaki-r Exp $");
#include <sys/types.h>
#include <sys/condvar.h>
@@ -457,19 +457,28 @@
/* Search through all the references on this CPU. */
LIST_FOREACH(psref, &pcpu->pcpu_head, psref_entry) {
- /* Sanity-check the reference. */
- KASSERTMSG((lwp_mismatch_ok || psref->psref_lwp == curlwp),
- "passive reference transferred from lwp %p to lwp %p",
- psref->psref_lwp, curlwp);
+ /* Sanity-check the reference's CPU. */
KASSERTMSG((psref->psref_cpu == curcpu()),
"passive reference transferred from CPU %u to CPU %u",
cpu_index(psref->psref_cpu), cpu_index(curcpu()));
- /* If it matches, stop here and answer yes. */
- if (psref->psref_target == target) {
- held = true;
- break;
- }
+ /* If it doesn't match, skip it and move on. */
+ if (psref->psref_target != target)
+ continue;
+
+ /*
+ * Sanity-check the reference's LWP if we are asserting
+ * via psref_held that this LWP holds it, but not if we
+ * are testing in psref_target_destroy whether any LWP
+ * still holds it.
+ */
+ KASSERTMSG((lwp_mismatch_ok || psref->psref_lwp == curlwp),
+ "passive reference transferred from lwp %p to lwp %p",
+ psref->psref_lwp, curlwp);
+
+ /* Stop here and report that we found it. */
+ held = true;
+ break;
}
/* Release the CPU list and restore interrupts. */
Home |
Main Index |
Thread Index |
Old Index