All of lore.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhltc@us.ibm.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "lkml, " <linux-kernel@vger.kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sripathi Kodi <sripathik@in.ibm.com>,
	John Stultz <johnstul@linux.vnet.ibm.com>,
	Peter Zijlstra <peterz@infradead.org>
Subject: Re: [TIP][RFC 6/7] futex: add requeue_pi calls
Date: Thu, 05 Mar 2009 21:27:25 -0800	[thread overview]
Message-ID: <49B0B43D.2030907@us.ibm.com> (raw)
In-Reply-To: <alpine.DEB.2.00.0903052119300.14535@gandalf.stny.rr.com>

Steven Rostedt wrote:
> On Thu, 5 Mar 2009, Darren Hart wrote:
>> As it turns out I missed setting RT_MUTEX_HAS_WAITERS on the rt_mutex in
>> rt_mutex_start_proxy_lock() - seems awfully silly in retrospect - but a
>> little non-obvious while writing it.  I added mark_rt_mutex_waiters()
>> after the call to task_blocks_on_rt_mutex() and the test has completed
>> more than 400 iterations successfully (it would fail after no more than
>> 2 most of the time before).
>>
>> Steven, there are several ways to set RT_MUTEX_HAS_WAITERS - but this
>> seemed like a reasonable approach, would you agree?  Since I'm holding
>> the wait_lock I don't technically need the atomic cmpxchg and could
>> probably just set it explicity - do you have a preference?
>>
> 
>> +
>> +/**
>> + * rt_mutex_finish_proxy_lock - Complete the taking of the lock initialized
>> on
>> + *                              our behalf by another thread.
>> + * @lock: the rt_mutex we were woken on
>> + * @to: the timeout, null if none. hrtimer should already have been started.
>> + * @waiter: the pre-initialized rt_mutex_waiter
>> + * @detect_deadlock: for use by __rt_mutex_slowlock
>> + *
>> + * Special API call for PI-futex requeue support
>> + */
>> +int rt_mutex_finish_proxy_lock(struct rt_mutex *lock,
>> +			       struct hrtimer_sleeper *to,
>> +			       struct rt_mutex_waiter *waiter,
>> +			       int detect_deadlock)
>> +{
>> +	int ret;
>> +
>> +	if (waiter->task)
>> +		schedule_rt_mutex(lock);
>> +
>> +	spin_lock(&lock->wait_lock);
>> +
>> +	set_current_state(TASK_INTERRUPTIBLE);
>> +
>> +	ret = __rt_mutex_slowlock(lock, TASK_INTERRUPTIBLE, to, waiter,
>> +				  detect_deadlock);
>> +
>> +	set_current_state(TASK_RUNNING);
>> +
>> +	if (unlikely(waiter->task))
>> +		remove_waiter(lock, waiter);
>> +
>> +	/*
>> +	 * try_to_take_rt_mutex() sets the waiter bit unconditionally. We
>> might
>> +	 * have to fix that up.
>> +	 */
>> +	fixup_rt_mutex_waiters(lock);
> 
> Darren,
> 
> I take it you are talking about the above.

Actually no, I was talking about rt_mutex_START_proxy_lock():

/**
 * rt_mutex_start_proxy_lock - prepare another task to take the lock
 *
 * @lock:		the rt_mutex to take
 * @waiter:		the rt_mutex_waiter initialized by the waiter
 * @task:		the task to prepare
 * @detext_deadlock:	passed to task_blocks_on_rt_mutex
 *
 * The lock should have an owner, and it should not be task.
 * Special API call for FUTEX_REQUEUE_PI support.
 */
int rt_mutex_start_proxy_lock(struct rt_mutex *lock,
			      struct rt_mutex_waiter *waiter,
			      struct task_struct *task, int detect_deadlock)
{
	int ret;

	spin_lock(&lock->wait_lock);
	ret = task_blocks_on_rt_mutex(lock, waiter, task, detect_deadlock);


I add the following line to fix the bug.  Question is, should I use this atomic
optimization here (under the lock->wait_lock) or should I just do 
"lock->owner |= RT_MUTEX_HAS_WAITERS" ?

=====>	mark_rt_mutex_waiters(lock);

	if (ret && !waiter->task) {
		/*
		 * Reset the return value. We might have
		 * returned with -EDEADLK and the owner
		 * released the lock while we were walking the
		 * pi chain.  Let the waiter sort it out.
		 */
		ret = 0;
	}
	spin_unlock(&lock->wait_lock);

	debug_rt_mutex_print_deadlock(waiter);

	return ret;
}



-- 
Darren Hart
IBM Linux Technology Center
Real-Time Linux Team

  reply	other threads:[~2009-03-06  5:27 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-03  0:02 [TIP][RFC 0/7] requeue pi implemenation Darren Hart
2009-03-03  0:09 ` [TIP][RFC 1/7] futex: futex_wait_queue_me() Darren Hart
2009-03-03  0:11 ` [TIP][RFC 2/7] futex: futex_top_waiter() Darren Hart
2009-03-07 15:16   ` Thomas Gleixner
2009-03-09 18:04     ` Darren Hart
2009-03-03  0:13 ` [TIP][RFC 3/7] futex: futex_lock_pi_atomic() Darren Hart
2009-03-03 13:03   ` Peter Zijlstra
2009-03-03 17:29     ` Darren Hart
2009-03-03  0:14 ` [TIP][RFC 4/7] futex: finish_futex_lock_pi() Darren Hart
2009-03-07 15:30   ` Thomas Gleixner
2009-03-09 18:05     ` Darren Hart
2009-03-03  0:16 ` [TIP][RFC 5/7] rt_mutex: add proxy lock routines Darren Hart
2009-03-07 15:44   ` Thomas Gleixner
2009-03-09 18:31     ` Darren Hart
2009-03-03  0:20 ` [TIP][RFC 6/7] futex: add requeue_pi calls Darren Hart
2009-03-04  7:53   ` Darren Hart
2009-03-05 16:51     ` Darren Hart
2009-03-06  1:42       ` Darren Hart
2009-03-06  2:21         ` Steven Rostedt
2009-03-06  5:27           ` Darren Hart [this message]
2009-03-07 15:50             ` Thomas Gleixner
2009-03-09 19:55               ` Darren Hart
2009-03-07  6:03         ` Sripathi Kodi
2009-03-09  9:48   ` Thomas Gleixner
2009-03-10  4:50     ` Darren Hart
2009-03-10 13:39       ` Thomas Gleixner
2009-03-03  0:23 ` [TIP][RFC 7/7] requeue pi testcase Darren Hart

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=49B0B43D.2030907@us.ibm.com \
    --to=dvhltc@us.ibm.com \
    --cc=johnstul@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sripathik@in.ibm.com \
    --cc=tglx@linutronix.de \
    /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.