There are a couple of blocked on type structures. One for mutexes, and one
for rtmutexes, and we also need one for futexes.
Instead of just adding another one to the task struct I combined them all into
a union. Since a waiter can only be blocked on one of the types at any given
time this should be safe.
I also usurped the pi_lock as the lock which protects all the blocked_on types.
Signed-off-by: Daniel Walker <dwalker@mvista.com>
---
include/linux/sched.h | 36 +++++++++++++++++++++++++++++++-----
kernel/fork.c | 2 --
kernel/mutex-debug.c | 25 ++++++++++++++++++-------
kernel/mutex-debug.h | 4 +++-
kernel/mutex.c | 6 +++++-
5 files changed, 57 insertions(+), 16 deletions(-)
Index: linux-2.6.25/include/linux/sched.h
===================================================================
--- linux-2.6.25.orig/include/linux/sched.h
+++ linux-2.6.25/include/linux/sched.h
@@ -1024,6 +1024,17 @@ struct sched_rt_entity {
#endif
};
+enum lock_waiter_type {
+ MUTEX_WAITER = 1,
+};
+
+struct lock_waiter_state {
+ enum lock_waiter_type lock_type;
+ union {
+ struct mutex_waiter *mutex_blocked_on;
+ };
+};
+
struct task_struct {
volatile long state; /* -1 unrunnable, 0 runnable, >0 stopped */
void *stack;
@@ -1201,7 +1212,7 @@ struct task_struct {
/* Protection of (de-)allocation: mm, files, fs, tty, keyrings */
spinlock_t alloc_lock;
- /* Protection of the PI data structures: */
+ /* Protects blocked_on field and PI waiters list. */
spinlock_t pi_lock;
#ifdef CONFIG_RT_MUTEXES
@@ -1211,10 +1222,12 @@ struct task_struct {
struct rt_mutex_waiter *pi_blocked_on;
#endif
-#ifdef CONFIG_DEBUG_MUTEXES
- /* mutex deadlock detection */
- struct mutex_waiter *blocked_on;
-#endif
+ /*
+ * Deadlock detection and priority inheritance handling,
+ * and any other out of line mutex operations
+ */
+ struct lock_waiter_state *blocked_on;
+
#ifdef CONFIG_TRACE_IRQFLAGS
unsigned int irq_events;
int ...