Source-Changes-HG archive

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

[src/trunk]: src/sys/kern Obtain proper initialized addresses of locks alloca...



details:   https://anonhg.NetBSD.org/src/rev/faae5ba7db17
branches:  trunk
changeset: 359224:faae5ba7db17
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Mon Feb 05 04:25:04 2018 +0000

description:
Obtain proper initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc

Initialized addresses of locks allocated by mutex_obj_alloc or rw_obj_alloc
were not useful because the addresses were mutex_obj_alloc or rw_obj_alloc
itself. What we want to know are callers of them.

diffstat:

 sys/kern/kern_mutex.c      |  22 +++++++++++++++-------
 sys/kern/kern_mutex_obj.c  |   8 +++++---
 sys/kern/kern_rwlock.c     |  17 ++++++++++++-----
 sys/kern/kern_rwlock_obj.c |   7 ++++---
 4 files changed, 36 insertions(+), 18 deletions(-)

diffs (174 lines):

diff -r 9c7380389d23 -r faae5ba7db17 sys/kern/kern_mutex.c
--- a/sys/kern/kern_mutex.c     Mon Feb 05 02:51:41 2018 +0000
+++ b/sys/kern/kern_mutex.c     Mon Feb 05 04:25:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex.c,v 1.70 2018/01/30 07:52:22 ozaki-r Exp $  */
+/*     $NetBSD: kern_mutex.c,v 1.71 2018/02/05 04:25:04 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.70 2018/01/30 07:52:22 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex.c,v 1.71 2018/02/05 04:25:04 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -327,8 +327,10 @@
  *     sleeps - see comments in mutex_vector_enter() about releasing
  *     mutexes unlocked.
  */
+void _mutex_init(kmutex_t *, kmutex_type_t, int, uintptr_t);
 void
-mutex_init(kmutex_t *mtx, kmutex_type_t type, int ipl)
+_mutex_init(kmutex_t *mtx, kmutex_type_t type, int ipl,
+    uintptr_t return_address)
 {
        bool dodebug;
 
@@ -354,18 +356,17 @@
 
        switch (type) {
        case MUTEX_NODEBUG:
-               dodebug = LOCKDEBUG_ALLOC(mtx, NULL,
-                   (uintptr_t)__builtin_return_address(0));
+               dodebug = LOCKDEBUG_ALLOC(mtx, NULL, return_address);
                MUTEX_INITIALIZE_SPIN(mtx, dodebug, ipl);
                break;
        case MUTEX_ADAPTIVE:
                dodebug = LOCKDEBUG_ALLOC(mtx, &mutex_adaptive_lockops,
-                   (uintptr_t)__builtin_return_address(0));
+                   return_address);
                MUTEX_INITIALIZE_ADAPTIVE(mtx, dodebug);
                break;
        case MUTEX_SPIN:
                dodebug = LOCKDEBUG_ALLOC(mtx, &mutex_spin_lockops,
-                   (uintptr_t)__builtin_return_address(0));
+                   return_address);
                MUTEX_INITIALIZE_SPIN(mtx, dodebug, ipl);
                break;
        default:
@@ -374,6 +375,13 @@
        }
 }
 
+void
+mutex_init(kmutex_t *mtx, kmutex_type_t type, int ipl)
+{
+
+       _mutex_init(mtx, type, ipl, (uintptr_t)__builtin_return_address(0));
+}
+
 /*
  * mutex_destroy:
  *
diff -r 9c7380389d23 -r faae5ba7db17 sys/kern/kern_mutex_obj.c
--- a/sys/kern/kern_mutex_obj.c Mon Feb 05 02:51:41 2018 +0000
+++ b/sys/kern/kern_mutex_obj.c Mon Feb 05 04:25:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_mutex_obj.c,v 1.5 2011/09/27 01:02:38 jym Exp $   */
+/*     $NetBSD: kern_mutex_obj.c,v 1.6 2018/02/05 04:25:04 ozaki-r Exp $       */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.5 2011/09/27 01:02:38 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_mutex_obj.c,v 1.6 2018/02/05 04:25:04 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -87,9 +87,11 @@
 mutex_obj_alloc(kmutex_type_t type, int ipl)
 {
        struct kmutexobj *mo;
+       extern void _mutex_init(kmutex_t *, kmutex_type_t, int, uintptr_t);
 
        mo = pool_cache_get(mutex_obj_cache, PR_WAITOK);
-       mutex_init(&mo->mo_lock, type, ipl);
+       _mutex_init(&mo->mo_lock, type, ipl,
+           (uintptr_t)__builtin_return_address(0));
        mo->mo_refcnt = 1;
 
        return (kmutex_t *)mo;
diff -r 9c7380389d23 -r faae5ba7db17 sys/kern/kern_rwlock.c
--- a/sys/kern/kern_rwlock.c    Mon Feb 05 02:51:41 2018 +0000
+++ b/sys/kern/kern_rwlock.c    Mon Feb 05 04:25:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rwlock.c,v 1.49 2018/01/30 07:52:22 ozaki-r Exp $ */
+/*     $NetBSD: kern_rwlock.c,v 1.50 2018/02/05 04:25:04 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.49 2018/01/30 07:52:22 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock.c,v 1.50 2018/02/05 04:25:04 ozaki-r Exp $");
 
 #define        __RWLOCK_PRIVATE
 
@@ -197,18 +197,25 @@
  *
  *     Initialize a rwlock for use.
  */
+void _rw_init(krwlock_t *, uintptr_t);
 void
-rw_init(krwlock_t *rw)
+_rw_init(krwlock_t *rw, uintptr_t return_address)
 {
        bool dodebug;
 
        memset(rw, 0, sizeof(*rw));
 
-       dodebug = LOCKDEBUG_ALLOC(rw, &rwlock_lockops,
-           (uintptr_t)__builtin_return_address(0));
+       dodebug = LOCKDEBUG_ALLOC(rw, &rwlock_lockops, return_address);
        RW_SETDEBUG(rw, dodebug);
 }
 
+void
+rw_init(krwlock_t *rw)
+{
+
+       _rw_init(rw, (uintptr_t)__builtin_return_address(0));
+}
+
 /*
  * rw_destroy:
  *
diff -r 9c7380389d23 -r faae5ba7db17 sys/kern/kern_rwlock_obj.c
--- a/sys/kern/kern_rwlock_obj.c        Mon Feb 05 02:51:41 2018 +0000
+++ b/sys/kern/kern_rwlock_obj.c        Mon Feb 05 04:25:04 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $        */
+/*     $NetBSD: kern_rwlock_obj.c,v 1.4 2018/02/05 04:25:04 ozaki-r Exp $      */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.3 2011/05/13 22:16:43 rmind Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_rwlock_obj.c,v 1.4 2018/02/05 04:25:04 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/atomic.h>
@@ -87,9 +87,10 @@
 rw_obj_alloc(void)
 {
        struct krwobj *ro;
+       extern void _rw_init(krwlock_t *, uintptr_t);
 
        ro = pool_cache_get(rw_obj_cache, PR_WAITOK);
-       rw_init(&ro->ro_lock);
+       _rw_init(&ro->ro_lock, (uintptr_t)__builtin_return_address(0));
        ro->ro_refcnt = 1;
 
        return (krwlock_t *)ro;



Home | Main Index | Thread Index | Old Index