All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@elte.hu>
To: David Singleton <dsingleton@mvista.com>
Cc: dino@in.ibm.com, linux-kernel@vger.kernel.org
Subject: Re: PI BUG with -rt13
Date: Fri, 18 Nov 2005 10:29:09 +0100	[thread overview]
Message-ID: <20051118092909.GC4858@elte.hu> (raw)
In-Reply-To: <437D0C59.1060607@mvista.com>


* David Singleton <dsingleton@mvista.com> wrote:

> >I was testing PI support in the -rt tree (-rt13) when I hit the BUG
> >below. I am using the BULL/Montavista glibc patches. However I would
> >think this can be reproduced using just plain FUTEX_WAKE/WAIT_ROBUST
> >APIs as well, though I havent tried.  I can send out the test code
> >if anybody is interested. I have attached the .config below.
> > 
> >

>    If I make the lock in the timer_base_s struct a raw spinlock this 
> BUG goes away.

that most likely just papers over the real bug. Given task-reference 
count bug i fixed in the robust/PI-futexes code (see the patch below) i 
suspect some more races and/or plain incorrect code.

[this patch below also converts the robust/PI-futex code to use RCU 
instead of the tasklist_lock - which should remove a major latency 
source from the futex code].

	Ingo

Index: linux/kernel/rt.c
===================================================================
--- linux.orig/kernel/rt.c
+++ linux/kernel/rt.c
@@ -2939,15 +2939,20 @@ EXPORT_SYMBOL(rt_mutex_owned_by);
  * and now own the lock, or negative values for failure, or positive
  * values for the amount of time we waited before getting the lock.
  */
-int fastcall down_futex(struct rt_mutex *lock, unsigned long time, pid_t owner_pid)
+int fastcall
+down_futex(struct rt_mutex *lock, unsigned long time, pid_t owner_pid)
 {
 	struct task_struct *owner_task = NULL;
 #ifdef CONFIG_DEBUG_DEADLOCKS
 	unsigned long eip = CALLER_ADDR0;
 #endif
-	read_lock(&tasklist_lock);
+	int ret;
+
+	rcu_read_lock();
 	owner_task = find_task_by_pid(owner_pid);
-	read_unlock(&tasklist_lock);
+	if (!get_task_struct_rcu(owner_task))
+		owner_task = NULL;
+	rcu_read_unlock();
 
 	if (!owner_task)
 		return -EOWNERDEAD;
@@ -2956,7 +2961,10 @@ int fastcall down_futex(struct rt_mutex 
 		__down_mutex(lock __EIP__);
 		rt_mutex_set_owner(lock, owner_task->thread_info);
 	}
-	return __down_interruptible(lock, time __EIP__);
+	ret = __down_interruptible(lock, time __EIP__);
+	put_task_struct(owner_task);
+
+	return ret;
 }
 EXPORT_SYMBOL(down_futex);
 

  reply	other threads:[~2005-11-18  9:29 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-11-17 16:18 PI BUG with -rt13 Dinakar Guniguntala
2005-11-17 16:41 ` Dinakar Guniguntala
2005-11-17 23:03 ` David Singleton
2005-11-18  9:29   ` Ingo Molnar [this message]
2005-11-18 13:21     ` Dinakar Guniguntala
2005-11-18 13:27       ` Ingo Molnar
2005-11-18 17:05         ` david singleton
2005-11-18 17:44           ` Ingo Molnar
2005-11-21 19:48             ` David Singleton
2005-11-21 21:26               ` Ingo Molnar
2005-11-22  2:01                 ` david singleton
2005-11-24 14:57                   ` Ingo Molnar
2005-11-24 20:26                     ` Dinakar Guniguntala
2005-11-24 20:32                       ` Dinakar Guniguntala
2005-11-24 22:25                         ` david singleton
2005-11-25  4:56                         ` david singleton
2005-11-25  7:34                           ` Dinakar Guniguntala
2005-11-25  8:04                             ` Dinakar Guniguntala
2005-11-25  5:04                       ` Ingo Molnar
2005-11-25 13:27                         ` Dinakar Guniguntala
2005-11-25  8:03                   ` Ingo Molnar
2005-11-22  2:13                 ` david singleton
     [not found]                 ` <8D664A17-5B07-11DA-A840-000A959BB91E@mvista.com>
2005-11-22  9:37                   ` Dinakar Guniguntala

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051118092909.GC4858@elte.hu \
    --to=mingo@elte.hu \
    --cc=dino@in.ibm.com \
    --cc=dsingleton@mvista.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.