summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_mutex.c
diff options
context:
space:
mode:
authorattilio <attilio@FreeBSD.org>2007-11-18 14:43:53 +0000
committerattilio <attilio@FreeBSD.org>2007-11-18 14:43:53 +0000
commitbfc761fdba732e46979638ae050d0477eaf4b2cb (patch)
tree85188d6cc1153cc1df464313f1de2d46f0d4f067 /sys/kern/kern_mutex.c
parent9dbec8e7dff5d2722f0ec81fca3a4d632eaadd19 (diff)
downloadFreeBSD-src-bfc761fdba732e46979638ae050d0477eaf4b2cb.zip
FreeBSD-src-bfc761fdba732e46979638ae050d0477eaf4b2cb.tar.gz
Expand lock class with the "virtual" function lc_assert which will offer
an unified way for all the lock primitives to express lock assertions. Currenty, lockmgrs and rmlocks don't have assertions, so just panic in that case. This will be a base for more callout improvements. Ok'ed by: jhb, jeff
Diffstat (limited to 'sys/kern/kern_mutex.c')
-rw-r--r--sys/kern/kern_mutex.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 036a277..cb054fd 100644
--- a/sys/kern/kern_mutex.c
+++ b/sys/kern/kern_mutex.c
@@ -84,6 +84,7 @@ __FBSDID("$FreeBSD$");
#define mtx_owner(m) ((struct thread *)((m)->mtx_lock & ~MTX_FLAGMASK))
+static void assert_mtx(struct lock_object *lock, int what);
#ifdef DDB
static void db_show_mtx(struct lock_object *lock);
#endif
@@ -98,6 +99,7 @@ static int unlock_spin(struct lock_object *lock);
struct lock_class lock_class_mtx_sleep = {
.lc_name = "sleep mutex",
.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
+ .lc_assert = assert_mtx,
#ifdef DDB
.lc_ddb_show = db_show_mtx,
#endif
@@ -107,6 +109,7 @@ struct lock_class lock_class_mtx_sleep = {
struct lock_class lock_class_mtx_spin = {
.lc_name = "spin mutex",
.lc_flags = LC_SPINLOCK | LC_RECURSABLE,
+ .lc_assert = assert_mtx,
#ifdef DDB
.lc_ddb_show = db_show_mtx,
#endif
@@ -135,6 +138,13 @@ static inline void lock_profile_init(void) {;}
#endif
void
+assert_mtx(struct lock_object *lock, int what)
+{
+
+ mtx_assert((struct mtx *)lock, what);
+}
+
+void
lock_mtx(struct lock_object *lock, int how)
{
OpenPOWER on IntegriCloud