Source-Changes-HG archive

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

[src/trunk]: src/sys/rump/librump/rumpkern rump: check if the mutex is surely...



details:   https://anonhg.NetBSD.org/src/rev/c755a4495069
branches:  trunk
changeset: 358391:c755a4495069
user:      ozaki-r <ozaki-r%NetBSD.org@localhost>
date:      Wed Dec 27 09:03:22 2017 +0000

description:
rump: check if the mutex is surely owned by the caller in mutex_exit

Unlocking a not-owned mutex wasn't detected well (it could detect if the mutex
is not held by anyone but that's not enough). Let's check it (the check is the
same as normal kernel's mutex).

If LOCKDEBUG is enabled, give the check over LOCKDEBUG because it can provide
better debugging information.

diffstat:

 sys/rump/librump/rumpkern/locks.c |  7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r 714939766bd5 -r c755a4495069 sys/rump/librump/rumpkern/locks.c
--- a/sys/rump/librump/rumpkern/locks.c Wed Dec 27 09:01:53 2017 +0000
+++ b/sys/rump/librump/rumpkern/locks.c Wed Dec 27 09:03:22 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: locks.c,v 1.78 2017/12/27 09:01:53 ozaki-r Exp $       */
+/*     $NetBSD: locks.c,v 1.79 2017/12/27 09:03:22 ozaki-r Exp $       */
 
 /*
  * Copyright (c) 2007-2011 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.78 2017/12/27 09:01:53 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: locks.c,v 1.79 2017/12/27 09:03:22 ozaki-r Exp $");
 
 #include <sys/param.h>
 #include <sys/kmem.h>
@@ -186,6 +186,9 @@
 mutex_exit(kmutex_t *mtx)
 {
 
+#ifndef LOCKDEBUG
+       KASSERT(mutex_owned(mtx));
+#endif
        UNLOCKED(mtx, false);
        rumpuser_mutex_exit(RUMPMTX(mtx));
 }



Home | Main Index | Thread Index | Old Index