Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Check pserialize_not_in_read_section for adaptive m...



details:   https://anonhg.NetBSD.org/src/rev/9620aa40518e
branches:  trunk
changeset: 992106:9620aa40518e
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Tue Aug 14 01:09:53 2018 +0000

description:
Check pserialize_not_in_read_section for adaptive mutexes and rwlocks

The overhead of the checks is not negligible so they're turned on only if both
DEBUG and LOCKDEBUG are enabled.

diffstat:

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

diffs (68 lines):

diff -r b5280a1dbf57 -r 9620aa40518e sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Tue Aug 14 01:06:01 2018 +0000
+++ b/sys/kern/kern_mutex.c     Tue Aug 14 01:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.73 2018/02/25 18:54:29 chs Exp $      */
+/*     $NetBSD: kern_mutex.c,v 1.74 2018/08/14 01:09:53 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.73 2018/02/25 18:54:29 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.74 2018/08/14 01:09:53 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -55,6 +55,7 @@
 #include <sys/lock.h>
 #include <sys/types.h>
 #include <sys/cpu.h>
+#include <sys/pserialize.h>
 
 #include <dev/lockstat.h>
 
@@ -523,6 +524,7 @@
        MUTEX_ASSERT(mtx, curthread != 0);
        MUTEX_ASSERT(mtx, !cpu_intr_p());
        MUTEX_WANTLOCK(mtx);
+       KDASSERT(pserialize_not_in_read_section());
 
        if (panicstr == NULL) {
                LOCKDEBUG_BARRIER(&kernel_lock, 1);
diff -r b5280a1dbf57 -r 9620aa40518e sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c    Tue Aug 14 01:06:01 2018 +0000
+++ b/sys/kern/kern_rwlock.c    Tue Aug 14 01:09:53 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rwlock.c,v 1.50 2018/02/05 04:25:04 ozaki-r Exp $ */
+/*     $NetBSD: kern_rwlock.c,v 1.51 2018/08/14 01:09:53 ozaki-r Exp $ */
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.50 2018/02/05 04:25:04 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.51 2018/08/14 01:09:53 ozaki-r Exp $");
 
 #define        __RWLOCK_PRIVATE
 
@@ -52,6 +52,7 @@
 #include <sys/cpu.h>
 #include <sys/atomic.h>
 #include <sys/lock.h>
+#include <sys/pserialize.h>
 
 #include <dev/lockstat.h>
 
@@ -289,6 +290,7 @@
        RW_ASSERT(rw, !cpu_intr_p());
        RW_ASSERT(rw, curthread != 0);
        RW_WANTLOCK(rw, op);
+       KDASSERT(pserialize_not_in_read_section());
 
        if (panicstr == NULL) {
                LOCKDEBUG_BARRIER(&kernel_lock, 1);



Home | Main Index | Thread Index | Old Index