summaryrefslogtreecommitdiff
path: root/kern
diff options
context:
space:
mode:
authorRichard Braun <rbraun@sceen.net>2018-01-07 00:35:46 +0100
committerRichard Braun <rbraun@sceen.net>2018-01-07 00:35:46 +0100
commit2396ae7dc601c9159ce1a86274133a7f90bf3aca (patch)
treed352cb9978e4c43693972235cb4c1a9dd8c5ebe9 /kern
parenta97a2bc6f1c24851ef19600a7bd15b211137abfe (diff)
kern/Kconfig: new MUTEX_DEBUG option
Diffstat (limited to 'kern')
-rw-r--r--kern/Kconfig10
-rw-r--r--kern/mutex/mutex_adaptive.c14
-rw-r--r--kern/mutex/mutex_plain.c14
-rw-r--r--kern/rtmutex.c14
4 files changed, 25 insertions, 27 deletions
diff --git a/kern/Kconfig b/kern/Kconfig
index 7c718d4c..26f5e5d9 100644
--- a/kern/Kconfig
+++ b/kern/Kconfig
@@ -81,3 +81,13 @@ config THREAD_STACK_GUARD
If unsure, disable.
endmenu
+
+menu "Debugging"
+
+config MUTEX_DEBUG
+ bool "Mutex debugging"
+ default n
+ ---help---
+ Enable mutex debugging and instrumentation.
+
+endmenu
diff --git a/kern/mutex/mutex_adaptive.c b/kern/mutex/mutex_adaptive.c
index 68b006ad..3e6b610b 100644
--- a/kern/mutex/mutex_adaptive.c
+++ b/kern/mutex/mutex_adaptive.c
@@ -31,11 +31,7 @@
#include <kern/thread.h>
#include <machine/cpu.h>
-#ifndef MUTEX_ADAPTIVE_DEBUG
-#define MUTEX_ADAPTIVE_DEBUG 0
-#endif /* MUTEX_ADAPTIVE_DEBUG */
-
-#if MUTEX_ADAPTIVE_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
enum {
MUTEX_ADAPTIVE_SC_SPINS,
@@ -95,10 +91,10 @@ mutex_adaptive_inc_sc(unsigned int index)
syscnt_inc(&mutex_adaptive_sc_array[index]);
}
-#else /* MUTEX_ADAPTIVE_DEBUG */
+#else /* CONFIG_MUTEX_DEBUG */
#define mutex_adaptive_setup_debug()
#define mutex_adaptive_inc_sc(x)
-#endif /* MUTEX_ADAPTIVE_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
static struct thread *
@@ -329,7 +325,7 @@ mutex_adaptive_setup(void)
}
INIT_OP_DEFINE(mutex_adaptive_setup,
-#if MUTEX_ADAPTIVE_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
INIT_OP_DEP(syscnt_setup, true),
-#endif /* MUTEX_ADAPTIVE_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
);
diff --git a/kern/mutex/mutex_plain.c b/kern/mutex/mutex_plain.c
index 2c655940..8945014f 100644
--- a/kern/mutex/mutex_plain.c
+++ b/kern/mutex/mutex_plain.c
@@ -27,11 +27,7 @@
#include <kern/sleepq.h>
#include <kern/syscnt.h>
-#ifndef MUTEX_PLAIN_DEBUG
-#define MUTEX_PLAIN_DEBUG 0
-#endif /* MUTEX_PLAIN_DEBUG */
-
-#if MUTEX_PLAIN_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
enum {
MUTEX_PLAIN_SC_WAIT_SUCCESSES,
@@ -70,10 +66,10 @@ mutex_plain_inc_sc(unsigned int index)
syscnt_inc(&mutex_plain_sc_array[index]);
}
-#else /* MUTEX_PLAIN_DEBUG */
+#else /* CONFIG_MUTEX_DEBUG */
#define mutex_plain_setup_debug()
#define mutex_plain_inc_sc(x)
-#endif /* MUTEX_PLAIN_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
static int
mutex_plain_lock_slow_common(struct mutex *mutex, bool timed, uint64_t ticks)
@@ -170,7 +166,7 @@ mutex_plain_setup(void)
}
INIT_OP_DEFINE(mutex_plain_setup,
-#if MUTEX_PLAIN_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
INIT_OP_DEP(syscnt_setup, true),
-#endif /* MUTEX_PLAIN_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
);
diff --git a/kern/rtmutex.c b/kern/rtmutex.c
index 00d87dfe..36c72a37 100644
--- a/kern/rtmutex.c
+++ b/kern/rtmutex.c
@@ -29,11 +29,7 @@
#include <kern/thread.h>
#include <kern/turnstile.h>
-#ifndef RTMUTEX_DEBUG
-#define RTMUTEX_DEBUG 0
-#endif /* RTMUTEX_DEBUG */
-
-#if RTMUTEX_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
enum {
RTMUTEX_SC_WAIT_SUCCESSES,
@@ -75,10 +71,10 @@ rtmutex_inc_sc(unsigned int index)
syscnt_inc(&rtmutex_sc_array[index]);
}
-#else /* RTMUTEX_DEBUG */
+#else /* CONFIG_MUTEX_DEBUG */
#define rtmutex_setup_debug()
#define rtmutex_inc_sc(x)
-#endif /* RTMUTEX_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
static struct thread *
rtmutex_get_thread(uintptr_t owner)
@@ -236,7 +232,7 @@ rtmutex_setup(void)
}
INIT_OP_DEFINE(rtmutex_setup,
-#if RTMUTEX_DEBUG
+#ifdef CONFIG_MUTEX_DEBUG
INIT_OP_DEP(syscnt_setup, true),
-#endif /* RTMUTEX_DEBUG */
+#endif /* CONFIG_MUTEX_DEBUG */
);