public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Darren Hart <dvhart@linux.intel.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Lai Jiangshan <laijs@cn.fujitsu.com>, Ingo Molnar <mingo@elte.hu>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Dave Young <hidave.darkstar@gmail.com>,
	Namhyung Kim <namhyung@gmail.com>,
	LKML <linux-kernel@vger.kernel.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] rtmutex: multiple candidate owners without unrelated boosting
Date: Thu, 16 Dec 2010 12:55:17 -0800	[thread overview]
Message-ID: <4D0A7CB5.1030406@linux.intel.com> (raw)
In-Reply-To: <alpine.LFD.2.00.1012141850460.12146@localhost6.localdomain6>

On 12/14/2010 12:07 PM, Thomas Gleixner wrote:
> B1;2401;0cOn Tue, 14 Dec 2010, Lai Jiangshan wrote:
>> Not advantage nor disadvantage
>> 1) Even we support multiple candidate owners, we hardly cause "thundering herd"
>>     the number of candidate owners is likely 1.
> 
> I'm not convinced about that function, see comments below
> 
>> 2) two APIs are changed.
>>     rt_mutex_owner() will not return pending owner
>>     rt_mutex_next_owner() always return the top owner, it is a candidate owner.
>> 	will not return NULL if we only have a pending owner.
>>     I have fixed the code that use these APIs.
> 
> I think we want a separate function which can be used by futex code,
> but that's a detail.


We do use both functions in the futex code.


> @@ -778,15 +778,6 @@ static int wake_futex_pi(u32 __user *uaddr, u32 uval, struct futex_q *this)
>  	new_owner = rt_mutex_next_owner(&pi_state->pi_mutex);
>  
>  	/*
> -	 * This happens when we have stolen the lock and the original
> -	 * pending owner did not enqueue itself back on the rt_mutex.
> -	 * Thats not a tragedy. We know that way, that a lock waiter
> -	 * is on the fly. We make the futex_q waiter the pending owner.
> -	 */
> -	if (!new_owner)
> -		new_owner = this->task;
> -


If I'm reading Lai's statement above correctly, the change actually just
eliminates the need for the !new_owner check, as in that case it will
return current. Is this correct? And indeed, Lai's patch removes it.
This looks correct to me.


> @@ -1647,18 +1638,20 @@ static int fixup_owner(u32 __user *uaddr, int fshared, struct futex_q *q,
>  		/*
>  		 * pi_state is incorrect, some other task did a lock steal and
>  		 * we returned due to timeout or signal without taking the
> -		 * rt_mutex. Too late. We can access the rt_mutex_owner without
> -		 * locking, as the other task is now blocked on the hash bucket
> -		 * lock. Fix the state up.


How does this patch change this behavior? Removing the comment and
adding the lock says that "the other task is now able to contend for the
pi_mutex".


> +		 * rt_mutex. Too late.
>  		 */
> +		raw_spin_lock(&q->pi_state->pi_mutex.wait_lock);
>  		owner = rt_mutex_owner(&q->pi_state->pi_mutex);
> +		if (!owner)
> +			owner = rt_mutex_next_owner(&q->pi_state->pi_mutex);
> +		raw_spin_unlock(&q->pi_state->pi_mutex.wait_lock);
>  		ret = fixup_pi_state_owner(uaddr, q, owner, fshared);
>  		goto out;
>  	}
>  
>  	/*
>  	 * Paranoia check. If we did not take the lock, then we should not be
> -	 * the owner, nor the pending owner, of the rt_mutex.
> +	 * the owner of the rt_mutex.


Is this changed because we could now be a "candidate owner" ?


>  	 */
>  	if (rt_mutex_owner(&q->pi_state->pi_mutex) == current)
>  		printk(KERN_ERR "fixup_owner: ret = %d pi-mutex: %p "


The other uses of rt_mutex_owner in futex.c don't appear to be impacted
by the change in API described above as they just compare the result to
current (futex_lock_pi and futex_wait_requeue_pi).


-- 
Darren Hart
Yocto Linux Kernel

  parent reply	other threads:[~2010-12-16 20:55 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-14  9:04 [PATCH] rtmutex: multiple candidate owners without unrelated boosting Lai Jiangshan
2010-12-14 14:01 ` Steven Rostedt
2010-12-14 16:44   ` Lai Jiangshan
2010-12-14 17:00     ` Steven Rostedt
2010-12-15  4:25       ` Lai Jiangshan
2010-12-14 20:07 ` Thomas Gleixner
2010-12-15  3:41   ` Lai Jiangshan
2010-12-15  4:16     ` Steven Rostedt
2010-12-15  8:09       ` [PATCH] rtmutex: ensure only the top waiter or higher priority task can take the lock and reduce " Lai Jiangshan
2010-12-15 12:07         ` Thomas Gleixner
2010-12-15 14:24           ` Lai Jiangshan
2010-12-15 14:52             ` Thomas Gleixner
2010-12-15 15:01               ` Steven Rostedt
2010-12-16 20:33             ` Darren Hart
2010-12-17  3:10               ` Lai Jiangshan
2010-12-17  3:17                 ` Steven Rostedt
2010-12-17  3:30                   ` Steven Rostedt
2010-12-15 15:04         ` Steven Rostedt
2010-12-23  9:07           ` Lai Jiangshan
2010-12-23 12:56             ` Steven Rostedt
2010-12-15 21:53         ` Steven Rostedt
2010-12-16  1:14           ` Lai Jiangshan
2010-12-16 13:56             ` Steven Rostedt
2010-12-16 14:07             ` Steven Rostedt
2011-01-06 14:50         ` Steven Rostedt
2011-01-10 11:37           ` Lai Jiangshan
2011-01-10 12:57             ` Steven Rostedt
2010-12-23  8:49       ` [PATCH V3] rtmutex: ensure only the top waiter or higher priority task can take the lock and remove " Lai Jiangshan
2011-01-12 17:03         ` Steven Rostedt
2011-01-12 17:04           ` Steven Rostedt
2011-01-12 17:05             ` Steven Rostedt
2011-01-14  9:09               ` [PATCH V4] " Lai Jiangshan
2011-01-21 17:34                 ` Thomas Gleixner
2011-01-22 14:07                   ` Steven Rostedt
2011-01-22 14:09                     ` Steven Rostedt
2011-01-31 14:30                 ` [tip:core/locking] rtmutex: Simplify PI algorithm and make highest prio task get lock tip-bot for Lai Jiangshan
2010-12-15  7:47     ` [PATCH] rtmutex: multiple candidate owners without unrelated boosting Thomas Gleixner
2010-12-16 20:55   ` Darren Hart [this message]
2010-12-23  7:25     ` Lai Jiangshan
2010-12-14 23:16 ` Steven Rostedt
2010-12-15  2:18 ` Steven Rostedt
2010-12-15  8:02   ` Thomas Gleixner
2010-12-15 14:02     ` Steven Rostedt
2010-12-15 14:16       ` Thomas Gleixner
2010-12-15 14:32         ` Steven Rostedt
2010-12-15 14:50           ` Thomas Gleixner

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=4D0A7CB5.1030406@linux.intel.com \
    --to=dvhart@linux.intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=hidave.darkstar@gmail.com \
    --cc=laijs@cn.fujitsu.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=namhyung@gmail.com \
    --cc=rostedt@goodmis.org \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox