Fri Jan 1 14:04:17 2021 UTC ()
Nix trailing whitespace.


(riastradh)
diff -r1.77 -r1.78 src/sys/kern/subr_lockdebug.c

cvs diff -r1.77 -r1.78 src/sys/kern/subr_lockdebug.c (expand / switch to unified diff)

--- src/sys/kern/subr_lockdebug.c 2020/05/15 13:09:02 1.77
+++ src/sys/kern/subr_lockdebug.c 2021/01/01 14:04:17 1.78
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: subr_lockdebug.c,v 1.77 2020/05/15 13:09:02 maxv Exp $ */ 1/* $NetBSD: subr_lockdebug.c,v 1.78 2021/01/01 14:04:17 riastradh Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc. 4 * Copyright (c) 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Andrew Doran. 8 * by Andrew Doran.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -24,27 +24,27 @@ @@ -24,27 +24,27 @@
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32/* 32/*
33 * Basic lock debugging code shared among lock primitives. 33 * Basic lock debugging code shared among lock primitives.
34 */ 34 */
35 35
36#include <sys/cdefs.h> 36#include <sys/cdefs.h>
37__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.77 2020/05/15 13:09:02 maxv Exp $"); 37__KERNEL_RCSID(0, "$NetBSD: subr_lockdebug.c,v 1.78 2021/01/01 14:04:17 riastradh Exp $");
38 38
39#ifdef _KERNEL_OPT 39#ifdef _KERNEL_OPT
40#include "opt_ddb.h" 40#include "opt_ddb.h"
41#endif 41#endif
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/proc.h> 44#include <sys/proc.h>
45#include <sys/systm.h> 45#include <sys/systm.h>
46#include <sys/kernel.h> 46#include <sys/kernel.h>
47#include <sys/kmem.h> 47#include <sys/kmem.h>
48#include <sys/lockdebug.h> 48#include <sys/lockdebug.h>
49#include <sys/sleepq.h> 49#include <sys/sleepq.h>
50#include <sys/cpu.h> 50#include <sys/cpu.h>
@@ -593,36 +593,36 @@ lockdebug_unlocked(const char *func, siz @@ -593,36 +593,36 @@ lockdebug_unlocked(const char *func, siz
593 } 593 }
594 TAILQ_REMOVE(&l->l_ld_locks, ld, ld_chain); 594 TAILQ_REMOVE(&l->l_ld_locks, ld, ld_chain);
595 } else { 595 } else {
596 uint16_t idx = (uint16_t)cpu_index(curcpu()); 596 uint16_t idx = (uint16_t)cpu_index(curcpu());
597 if (__predict_false(ld->ld_cpu != idx)) { 597 if (__predict_false(ld->ld_cpu != idx)) {
598 lockdebug_abort1(func, line, ld, s, 598 lockdebug_abort1(func, line, ld, s,
599 "not held by current CPU", true); 599 "not held by current CPU", true);
600 return; 600 return;
601 } 601 }
602 TAILQ_REMOVE(&curcpu()->ci_data.cpu_ld_locks, ld, 602 TAILQ_REMOVE(&curcpu()->ci_data.cpu_ld_locks, ld,
603 ld_chain); 603 ld_chain);
604 } 604 }
605 ld->ld_flags &= ~LD_LOCKED; 605 ld->ld_flags &= ~LD_LOCKED;
606 ld->ld_unlocked = where;  606 ld->ld_unlocked = where;
607 ld->ld_lwp = NULL; 607 ld->ld_lwp = NULL;
608 } 608 }
609 __cpu_simple_unlock(&ld->ld_spinlock); 609 __cpu_simple_unlock(&ld->ld_spinlock);
610 splx(s); 610 splx(s);
611} 611}
612 612
613/* 613/*
614 * lockdebug_barrier: 614 * lockdebug_barrier:
615 *  615 *
616 * Panic if we hold more than one specified lock, and optionally, if we 616 * Panic if we hold more than one specified lock, and optionally, if we
617 * hold any sleep locks. 617 * hold any sleep locks.
618 */ 618 */
619void 619void
620lockdebug_barrier(const char *func, size_t line, volatile void *onelock, 620lockdebug_barrier(const char *func, size_t line, volatile void *onelock,
621 int slplocks) 621 int slplocks)
622{ 622{
623 struct lwp *l = curlwp; 623 struct lwp *l = curlwp;
624 lockdebug_t *ld; 624 lockdebug_t *ld;
625 int s; 625 int s;
626 626
627 if (__predict_false(panicstr != NULL || ld_panic)) 627 if (__predict_false(panicstr != NULL || ld_panic))
628 return; 628 return;
@@ -1013,27 +1013,27 @@ lockdebug_dismiss(void) @@ -1013,27 +1013,27 @@ lockdebug_dismiss(void)
1013 * lockdebug_abort: 1013 * lockdebug_abort:
1014 * 1014 *
1015 * An error has been trapped - dump lock info and call panic(). 1015 * An error has been trapped - dump lock info and call panic().
1016 */ 1016 */
1017void 1017void
1018lockdebug_abort(const char *func, size_t line, const volatile void *lock, 1018lockdebug_abort(const char *func, size_t line, const volatile void *lock,
1019 lockops_t *ops, const char *msg) 1019 lockops_t *ops, const char *msg)
1020{ 1020{
1021#ifdef LOCKDEBUG 1021#ifdef LOCKDEBUG
1022 lockdebug_t *ld; 1022 lockdebug_t *ld;
1023 int s; 1023 int s;
1024 1024
1025 s = splhigh(); 1025 s = splhigh();
1026 if ((ld = lockdebug_lookup(func, line, lock,  1026 if ((ld = lockdebug_lookup(func, line, lock,
1027 (uintptr_t) __builtin_return_address(0))) != NULL) { 1027 (uintptr_t) __builtin_return_address(0))) != NULL) {
1028 lockdebug_abort1(func, line, ld, s, msg, true); 1028 lockdebug_abort1(func, line, ld, s, msg, true);
1029 return; 1029 return;
1030 } 1030 }
1031 splx(s); 1031 splx(s);
1032#endif /* LOCKDEBUG */ 1032#endif /* LOCKDEBUG */
1033 1033
1034 /* 1034 /*
1035 * Don't make the situation worse if the system is already going 1035 * Don't make the situation worse if the system is already going
1036 * down in flames. Once a panic is triggered, lockdebug state 1036 * down in flames. Once a panic is triggered, lockdebug state
1037 * becomes stale and cannot be trusted. 1037 * becomes stale and cannot be trusted.
1038 */ 1038 */
1039 if (atomic_inc_uint_nv(&ld_panic) > 1) 1039 if (atomic_inc_uint_nv(&ld_panic) > 1)