Re: 2.6.14-rc3-rt2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2005-10-04 at 22:45 +0200, Thomas Gleixner wrote:
> 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

Sorry, did not refresh before sending

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,22 @@ 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_down(l) do { } while(0)
+#define account_mutex_owner_up(l) do { } while(0)
 #endif
 
 #ifdef CONFIG_RT_DEADLOCK_DETECT
@@ -1241,13 +1257,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 +1595,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 +1654,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 +1664,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 +1717,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 +1733,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 +2893,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 [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux