[PATCH 08/12] locking/mutex: Init name properly w/ CONFIG_LOCK_INFO

Namhyung Kim
2022-02-08T18:43:03Z

The mutex.dep_map.name was set in debug_mutex_init() which is defined
only if CONFIG_DEBUG_MUTEXES is on. Let's fix it to work with
CONFIG_LOCK_INFO as well.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
kernel/locking/mutex.h | 7 +++++++
1 file changed, 7 insertions(+)

diff --git a/kernel/locking/mutex.h b/kernel/locking/mutex.h
index 0b2a79c4013b..b7b584ecdfef 100644
--- a/kernel/locking/mutex.h
+++ b/kernel/locking/mutex.h
@@ -41,5 +41,12 @@ extern void debug_mutex_init(struct mutex *lock, const char *name,
# define debug_mutex_add_waiter(lock, waiter, ti) do { } while (0)
# define debug_mutex_remove_waiter(lock, waiter, ti) do { } while (0)
# define debug_mutex_unlock(lock) do { } while (0)
+
+#ifdef CONFIG_LOCK_INFO
+# define debug_mutex_init(lock, name, key) \
+ lockdep_set_class_and_name(lock, key, name)
+#else
# define debug_mutex_init(lock, name, key) do { } while (0)
+#endif /* !CONFIG_LOCK_INFO */
+
#endif /* !CONFIG_DEBUG_MUTEXES */
--
2.35.0.263.gb82422642f-goog