PI-futex: rt-mutex debug
Subsystems (3)
PATCH 7/10 PI-futex: rt-mutex debug
From: Ingo Molnar <[email protected]>
runtime debugging functionality for rt-mutexes.
Signed-off-by Ingo Molnar <[email protected]>
Signed-off-by Thomas Gleixner <[email protected]>
Signed-off-by Arjan van de Ven <[email protected]>
----
include/linux/mm.h | 1 include/linux/rtmutex.h | 15 + kernel/Makefile | 1 kernel/exit.c | 1 kernel/rtmutex-debug.c | 511 ++++++++++++++++++++++++++++++++++++++++++++++++ kernel/rtmutex-debug.h | 32 +++ lib/Kconfig.debug | 13 + mm/slab.c | 1 8 files changed, 574 insertions(+), 1 deletion(-)
include/linux/mm.h +1 -0
@@ -1070,6 +1070,7 @@ static inline void debug_check_no_locks_freed(const void *from, unsigned long len) {mutex_debug_check_no_locks_freed (from, len); +rt_mutex_debug_check_no_locks_freed (from, len); }#ifndef CONFIG_DEBUG_PAGEALLOC
include/linux/rtmutex.h +14 -1
@@ -41,6 +41,19 @@ struct rt_mutex_waiter;struct hrtimer_sleeper ;#ifdef CONFIG_DEBUG_RT_MUTEXES +extern int rt_mutex_debug_check_no_locks_freed (const void *from, +unsigned long len); +extern void rt_mutex_debug_check_no_locks_held (struct task_struct *task); +#else +static inline int rt_mutex_debug_check_no_locks_freed (const void *from, +unsigned long len) + { +return 0 ; + } +# define rt_mutex_debug_check_no_locks_held (task) do { } while (0) +#endif + +#ifdef CONFIG_DEBUG_RT_MUTEXES # define __DEBUG_RT_MUTEX_INITIALIZER (mutexname) \ , .name = #mutexname, .file = __FILE__, .line = __LINE__# define rt_mutex_init (mutex) __rt_mutex_init(mutex, __FUNCTION__)
@@ -48,7 +61,7 @@ struct hrtimer_sleeper;#else # define __DEBUG_RT_MUTEX_INITIALIZER (mutexname)# define rt_mutex_init (mutex) __rt_mutex_init(mutex, NULL) -# define rt_mutex_debug_task_free (t) do { } while (0) +# define rt_mutex_debug_task_free (t) do { } while (0)#endif #define __RT_MUTEX_INITIALIZER (mutexname) \
kernel/Makefile +1 -0
@@ -17,6 +17,7 @@ ifeq ($(CONFIG_COMPAT),y) obj-$(CONFIG_FUTEX) += futex_compat.o endif obj-$(CONFIG_RT_MUTEXES) += rtmutex.o +obj-$(CONFIG_DEBUG_RT_MUTEXES) += rtmutex-debug.o obj-$(CONFIG_GENERIC_ISA_DMA) += dma.o obj-$(CONFIG_SMP) += cpu.o spinlock.o obj-$(CONFIG_DEBUG_SPINLOCK) += spinlock.o
kernel/exit.c +1 -0
@@ -931,6 +931,7 @@ fastcall NORET_TYPE void do_exit(long co* If DEBUG_MUTEXES is on, make sure we are holding no locks: */ mutex_debug_check_no_locks_held (tsk); +rt_mutex_debug_check_no_locks_held (tsk);if (tsk->io_context)exit_io_context ();
kernel/rtmutex-debug.c new file +511 -0
511 lines not on this page · raw message
kernel/rtmutex-debug.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* RT-Mutexes: blocking mutual exclusion locks with PI support +* +* started by Ingo Molnar and Thomas Gleixner: +* +* Copyright (C) 2004-2006 Red Hat, Inc., Ingo Molnar <[email protected]> +* Copyright (C) 2006, Timesys Corp., Thomas Gleixner <[email protected]> +* +* This file contains macros used solely by rtmutex.c. Debug version. +*/ + +#include <linux/rtmutex_internal.h> + +#define __IP_DECL__ , unsigned long ip +#define __IP__ , ip +#define __RET_IP__ , (unsigned long)__builtin_return_address(0) + +extern void +rt_mutex_deadlock_account_lock (struct rt_mutex *lock,struct task_struct *task); +extern void rt_mutex_deadlock_account_unlock (struct task_struct *task); +extern void debug_rt_mutex_init_waiter (struct rt_mutex_waiter *waiter); +extern void debug_rt_mutex_free_waiter (struct rt_mutex_waiter *waiter); +extern void debug_rt_mutex_init (struct rt_mutex *lock,const char *name); +extern void debug_rt_mutex_lock(struct rt_mutex *lock __IP_DECL__); +extern void debug_rt_mutex_unlock (struct rt_mutex *lock); +extern void debug_rt_mutex_proxy_unlock (struct rt_mutex *lock); +extern void debug_rt_mutex_deadlock (int detect,struct rt_mutex_waiter *waiter, +struct rt_mutex *lock); +extern void debug_rt_mutex_print_deadlock (struct rt_mutex_waiter *waiter); +# define debug_rt_mutex_detect_deadlock (d) (1) +# define debug_rt_mutex_reset_waiter (w) \ + do { (w)->deadlock_lock = NULL; } while (0)
lib/Kconfig.debug +13 -0
@@ -121,6 +121,19 @@ config DEBUG_MUTEXES This allows mutex semantics violations and mutex related deadlocks (lockups) to be detected and reported automatically. +config DEBUG_RT_MUTEXES + bool "RT Mutex debugging, deadlock detection" + default y + depends on DEBUG_KERNEL && RT_MUTEXES + help + This allows rt mutex semantics violations and rt mutex related + deadlocks (lockups) to be detected and reported automatically. + +config DEBUG_PI_LIST + bool + default y + depends on DEBUG_RT_MUTEXES + config DEBUG_SPINLOCK bool "Spinlock debugging" depends on DEBUG_KERNEL
mm/slab.c +1 -0
@@ -106,6 +106,7 @@#include <linux/nodemask.h> #include <linux/mempolicy.h> #include <linux/mutex.h> +#include <linux/rtmutex.h> #include <asm/uaccess.h> #include <asm/cacheflush.h>