aboutsummaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorAttilio Rao <attilio@FreeBSD.org>2007-11-18 14:43:53 +0000
committerAttilio Rao <attilio@FreeBSD.org>2007-11-18 14:43:53 +0000
commitf9721b43ed506f2ab7b1a60c6b92a9e4a360c6aa (patch)
tree85188d6cc1153cc1df464313f1de2d46f0d4f067 /sys/kern
parent7c7454fe95c01eb79bb11d19e1c97ac6a932594a (diff)
downloadsrc-f9721b43ed506f2ab7b1a60c6b92a9e4a360c6aa.tar.gz
src-f9721b43ed506f2ab7b1a60c6b92a9e4a360c6aa.zip
Notes
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_lock.c9
-rw-r--r--sys/kern/kern_mutex.c10
-rw-r--r--sys/kern/kern_rmlock.c9
-rw-r--r--sys/kern/kern_rwlock.c9
-rw-r--r--sys/kern/kern_sx.c9
5 files changed, 46 insertions, 0 deletions
diff --git a/sys/kern/kern_lock.c b/sys/kern/kern_lock.c
index 72566305c47f..6a5f213c177d 100644
--- a/sys/kern/kern_lock.c
+++ b/sys/kern/kern_lock.c
@@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$");
#include <sys/stack.h>
#endif
+static void assert_lockmgr(struct lock_object *lock, int what);
#ifdef DDB
#include <ddb/ddb.h>
static void db_show_lockmgr(struct lock_object *lock);
@@ -70,6 +71,7 @@ static int unlock_lockmgr(struct lock_object *lock);
struct lock_class lock_class_lockmgr = {
.lc_name = "lockmgr",
.lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
+ .lc_assert = assert_lockmgr,
#ifdef DDB
.lc_ddb_show = db_show_lockmgr,
#endif
@@ -83,6 +85,13 @@ struct lock_class lock_class_lockmgr = {
*/
void
+assert_lockmgr(struct lock_object *lock, int what)
+{
+
+ panic("lockmgr locks do not support assertions");
+}
+
+void
lock_lockmgr(struct lock_object *lock, int how)
{
diff --git a/sys/kern/kern_mutex.c b/sys/kern/kern_mutex.c
index 036a2770e8d0..cb054fd38c2b 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)
{
diff --git a/sys/kern/kern_rmlock.c b/sys/kern/kern_rmlock.c
index 276aee62606c..cbf5cc5c955b 100644
--- a/sys/kern/kern_rmlock.c
+++ b/sys/kern/kern_rmlock.c
@@ -71,12 +71,14 @@ static __inline void compiler_memory_barrier(void) {
__asm __volatile("":::"memory");
}
+static void assert_rm(struct lock_object *lock, int what);
static void lock_rm(struct lock_object *lock, int how);
static int unlock_rm(struct lock_object *lock);
struct lock_class lock_class_rm = {
.lc_name = "rm",
.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE,
+ .lc_assert = assert_rm,
#if 0
#ifdef DDB
.lc_ddb_show = db_show_rwlock,
@@ -87,6 +89,13 @@ struct lock_class lock_class_rm = {
};
static void
+assert_rm(struct lock_object *lock, int what)
+{
+
+ panic("assert_rm called");
+}
+
+static void
lock_rm(struct lock_object *lock, int how) {
panic("lock_rm called");
}
diff --git a/sys/kern/kern_rwlock.c b/sys/kern/kern_rwlock.c
index 809e526c3e7a..315f8875eda1 100644
--- a/sys/kern/kern_rwlock.c
+++ b/sys/kern/kern_rwlock.c
@@ -59,12 +59,14 @@ CTASSERT((RW_RECURSE & LO_CLASSFLAGS) == RW_RECURSE);
static void db_show_rwlock(struct lock_object *lock);
#endif
+static void assert_rw(struct lock_object *lock, int what);
static void lock_rw(struct lock_object *lock, int how);
static int unlock_rw(struct lock_object *lock);
struct lock_class lock_class_rw = {
.lc_name = "rw",
.lc_flags = LC_SLEEPLOCK | LC_RECURSABLE | LC_UPGRADABLE,
+ .lc_assert = assert_rw,
#ifdef DDB
.lc_ddb_show = db_show_rwlock,
#endif
@@ -103,6 +105,13 @@ struct lock_class lock_class_rw = {
#endif
void
+assert_rw(struct lock_object *lock, int what)
+{
+
+ rw_assert((struct rwlock *)lock, what);
+}
+
+void
lock_rw(struct lock_object *lock, int how)
{
struct rwlock *rw;
diff --git a/sys/kern/kern_sx.c b/sys/kern/kern_sx.c
index 8e99ee35affb..1e3f135eaf7c 100644
--- a/sys/kern/kern_sx.c
+++ b/sys/kern/kern_sx.c
@@ -103,6 +103,7 @@ CTASSERT(((SX_ADAPTIVESPIN | SX_RECURSE) & LO_CLASSFLAGS) ==
*/
#define sx_recursed(sx) ((sx)->sx_recurse != 0)
+static void assert_sx(struct lock_object *lock, int what);
#ifdef DDB
static void db_show_sx(struct lock_object *lock);
#endif
@@ -112,6 +113,7 @@ static int unlock_sx(struct lock_object *lock);
struct lock_class lock_class_sx = {
.lc_name = "sx",
.lc_flags = LC_SLEEPLOCK | LC_SLEEPABLE | LC_RECURSABLE | LC_UPGRADABLE,
+ .lc_assert = assert_sx,
#ifdef DDB
.lc_ddb_show = db_show_sx,
#endif
@@ -124,6 +126,13 @@ struct lock_class lock_class_sx = {
#endif
void
+assert_sx(struct lock_object *lock, int what)
+{
+
+ sx_assert((struct sx *)lock, what);
+}
+
+void
lock_sx(struct lock_object *lock, int how)
{
struct sx *sx;