Re: 2.6.14-rc3-rt2

From: Thomas Gleixner
Date: Tue Oct 04 2005 - 15:44:10 EST


On Tue, 2005-10-04 at 11:58 -0700, Mark Knecht wrote:
> > I guess its related to the priority leak I'm tracking down right now.
> > Can you please set following config options and check if you get a bug
> > similar to this ?
> >
> > BUG: init/1: leaked RT prio 98 (116)?
> >
> > Steven, it goes away when deadlock detection is enabled. Any pointers

Thats actually a red hering caused by asymetric accounting which only
happens when

CONFIG_DEBUG_PREEMPT=y
and
# CONFIG_RT_DEADLOCK_DETECT is not set

tglx


Index: linux-2.6.14-rc3-rt8-ep/kernel/rt.c
===================================================================
--- linux-2.6.14-rc3-rt8-ep.orig/kernel/rt.c
+++ linux-2.6.14-rc3-rt8-ep/kernel/rt.c
@@ -295,6 +295,21 @@ void check_preempt_wakeup(struct task_st
dump_stack();
}
}
+
+static inline void account_mutex_owner_down(struct rt_mutex *lock)
+{
+ current->owned_lock[current->lock_count] = lock;
+ current->lock_count++;
+}
+
+static inline void account_mutex_owner_up(struct rt_mutex *lock)
+{
+ current->lock_count--;
+ current->owned_lock[current->lock_count] = NULL;
+}
+
+#else
+#define account_mutex_owner(l) do { } while(0)
#endif

#ifdef CONFIG_RT_DEADLOCK_DETECT
@@ -1241,13 +1256,13 @@ static int __grab_lock(struct rt_mutex *
list_del_init(&lock->held_list);
#endif
#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPT_RT)
+ owner->lock_count--;
if (owner->lock_count < 0 || owner->lock_count >= MAX_LOCK_STACK) {
TRACE_OFF();
printk("BUG: %s/%d: lock count of %u\n",
owner->comm, owner->pid, owner->lock_count);
dump_stack();
}
- owner->lock_count--;
owner->owned_lock[owner->lock_count] = NULL;
#endif
return 1;
@@ -1579,13 +1594,13 @@ ____up_mutex(struct rt_mutex *lock, int
lock->owner = NULL;
_raw_spin_unlock(&lock->wait_lock);
#if defined(CONFIG_DEBUG_PREEMPT) && defined(CONFIG_PREEMPT_RT)
+ current->lock_count--;
if (current->lock_count < 0 || current->lock_count >= MAX_LOCK_STACK) {
TRACE_OFF();
printk("BUG: %s/%d: lock count of %u\n",
current->comm, current->pid, current->lock_count);
dump_stack();
}
- current->lock_count--;
current->owned_lock[current->lock_count] = NULL;
if (!current->lock_count && !rt_prio(current->normal_prio) &&
rt_prio(current->prio)) {
@@ -1638,6 +1653,8 @@ static inline void __down_mutex_inline(s

if (unlikely(cmpxchg(&lock->owner, NULL, ti)))
___down_mutex(lock __EIP__);
+ else
+ account_mutex_owner_down(lock);
}

static inline void __down_inline(struct rt_mutex *lock __EIP_DECL__)
@@ -1646,6 +1663,8 @@ static inline void __down_inline(struct

if (unlikely(cmpxchg(&lock->owner, NULL, ti)))
___down(lock __EIP__);
+ else
+ account_mutex_owner_down(lock);
}

void __sched __down_mutex(struct rt_mutex *lock __EIP_DECL__)
@@ -1697,6 +1716,8 @@ static inline void

if (unlikely(cmpxchg(&lock->owner, ti, NULL) != ti))
___up_mutex_savestate(lock __EIP__);
+ else
+ account_mutex_owner_up(lock);
}

void __sched __up_mutex_savestate(struct rt_mutex *lock __EIP_DECL__)
@@ -1711,6 +1732,8 @@ __up_mutex_nosavestate_inline(struct rt_

if (unlikely(cmpxchg(&lock->owner, ti, NULL) != ti))
___up_mutex_nosavestate(lock __EIP__);
+ else
+ account_mutex_owner_up(lock);
}

void __sched __up_mutex_nosavestate(struct rt_mutex *lock __EIP_DECL__)
@@ -2869,6 +2892,9 @@ void fastcall rt_mutex_set_owner(struct
*/
#ifdef CONFIG_DEBUG_PREEMPT
current->lock_count--;
+ current->owned_lock[current->lock_count] = NULL;
+ t->task->owned_lock[t->task->lock_count] = lock;
+ t->task->lock_count++;
#endif
lock->owner = t;
}



-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/