From: "Gregory Haskins" <ghaskins@novell.com>
To: "Steven Rostedt" <rostedt@goodmis.org>
Cc: <mingo@elte.hu>, <tglx@linutronix.de>,
"Moiz Kohari" <MKohari@novell.com>,
"Peter Morreale" <PMorreale@novell.com>,
"Sven Dietrich" <SDietrich@novell.com>,
<linux-kernel@vger.kernel.org>, <linux-rt-users@vger.kernel.org>
Subject: Re: [PATCH 5/5] remove the extra call to try_to_take_lock
Date: Fri, 23 May 2008 21:30:39 -0600 [thread overview]
Message-ID: <4837539F.BA47.005A.0@novell.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0805232301080.12686@gandalf.stny.rr.com>
>>> On Fri, May 23, 2008 at 11:02 PM, in message
<Pine.LNX.4.58.0805232301080.12686@gandalf.stny.rr.com>, Steven Rostedt
<rostedt@goodmis.org> wrote:
> On Tue, 20 May 2008, Gregory Haskins wrote:
>
>> From: Peter W. Morreale <pmorreale@novell.com>
>>
>> Remove the redundant attempt to get the lock. While it is true that the
>> exit path with this patch adds an un-necessary xchg (in the event the
>> lock is granted without further traversal in the loop) experimentation
>> shows that we almost never encounter this situation.
>>
>> Signed-off-by: Peter W. Morreale <pmorreale@novell.com>
>> Signed-off-by: Gregory Haskins <ghaskins@novell.com>
>> ---
>>
>> kernel/rtmutex.c | 6 ------
>> 1 files changed, 0 insertions(+), 6 deletions(-)
>>
>> diff --git a/kernel/rtmutex.c b/kernel/rtmutex.c
>> index ec1f7d4..1da7813 100644
>> --- a/kernel/rtmutex.c
>> +++ b/kernel/rtmutex.c
>> @@ -785,12 +785,6 @@ rt_spin_lock_slowlock(struct rt_mutex *lock)
>> spin_lock_irqsave(&lock->wait_lock, flags);
>> init_lists(lock);
>>
>> - /* Try to acquire the lock again: */
>> - if (do_try_to_take_rt_mutex(lock, STEAL_LATERAL)) {
>> - spin_unlock_irqrestore(&lock->wait_lock, flags);
>> - return;
>> - }
>> -
>
> This would suggested that lock stealing doesn't happen. On lock stealing,
> this is the condition that is triggered and we have a nice quick exit.
Its not that we are saying it doesn't happen. Rather, we are saying the overhead of exiting from the second call (and only remaining call after this patch) is not as significant as it would seem on paper (based on empirical data). In essence, it adds an xchg to the steal-case which is not "great", but....
..conversely, if the first test fails, the second test will *always* fail (since the lock->wait_lock is held across both). This extra overhead actually *does* result in a measurable degradation of performance in our testing.
Another way to write the patch is to do more of a "do/while" style with the try_to_take is done later in the loop. You could then retain the fast-path exit in that case. I actually wrote a patch like that at one point, but I think Peter's here was faster. I don't recall the reason why that was off the top of my head, but I remember I dropped my patch in favor of his because of the difference.
Regards,
-Greg
>
> -- Steve
>
>
>
>> BUG_ON(rt_mutex_owner(lock) == current);
>>
>> /*
>>
next prev parent reply other threads:[~2008-05-24 3:30 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-20 14:49 [PATCH 0/5] RT: adaptive-lock enhancements Gregory Haskins
2008-05-20 14:49 ` [PATCH 1/5] optimize rt lock wakeup Gregory Haskins
2008-05-20 14:49 ` [PATCH 2/5] sched: make task->oncpu available in all configurations Gregory Haskins
2008-05-20 14:49 ` [PATCH 3/5] rtmutex: use task->oncpu to save a call Gregory Haskins
2008-05-20 14:49 ` [PATCH 4/5] adjust pi_lock usage in wakeup Gregory Haskins
2008-05-20 14:49 ` [PATCH 5/5] remove the extra call to try_to_take_lock Gregory Haskins
2008-05-24 3:02 ` Steven Rostedt
2008-05-24 3:30 ` Gregory Haskins [this message]
2008-05-24 14:11 ` Peter W. Morreale
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=4837539F.BA47.005A.0@novell.com \
--to=ghaskins@novell.com \
--cc=MKohari@novell.com \
--cc=PMorreale@novell.com \
--cc=SDietrich@novell.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=rostedt@goodmis.org \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox