Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Check if adaptive mutex isn't called in interrupt c...



details:   https://anonhg.NetBSD.org/src/rev/2c169a6fbf94
branches:  trunk
changeset: 829577:2c169a6fbf94
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Feb 06 07:46:24 2018 +0000

description:
Check if adaptive mutex isn't called in interrupt context

By this check, we can notice this programming error without LOCKDEBUG.
The same check exists in rw_enter.

diffstat:

 sys/kern/kern_mutex.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (34 lines):

diff -r 9d60c5a6aef4 -r 2c169a6fbf94 sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Tue Feb 06 07:04:01 2018 +0000
+++ b/sys/kern/kern_mutex.c     Tue Feb 06 07:46:24 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.71 2018/02/05 04:25:04 ozaki-r Exp $  */
+/*     $NetBSD: kern_mutex.c,v 1.72 2018/02/06 07:46:24 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.71 2018/02/05 04:25:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.72 2018/02/06 07:46:24 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -54,6 +54,7 @@
 #include <sys/intr.h>
 #include <sys/lock.h>
 #include <sys/types.h>
+#include <sys/cpu.h>
 
 #include <dev/lockstat.h>
 
@@ -515,6 +516,7 @@
 
        MUTEX_DASSERT(mtx, MUTEX_ADAPTIVE_P(mtx));
        MUTEX_ASSERT(mtx, curthread != 0);
+       MUTEX_ASSERT(mtx, !cpu_intr_p());
        MUTEX_WANTLOCK(mtx);
 
        if (panicstr == NULL) {



Home | Main Index | Thread Index | Old Index