public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Maxim Kuvyrkov <maxim@codesourcery.com>
To: Chris Metcalf <cmetcalf@tilera.com>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
	GLIBC Devel	<libc-alpha@sourceware.org>,
	<libc-ports@sourceware.org>,
	Tom de Vries	<vries@codesourcery.com>
Subject: Re: [PATCH] Optimize libc_lock_lock for MIPS XLP.
Date: Fri, 15 Jun 2012 02:50:00 -0000	[thread overview]
Message-ID: <C8A2E1C0-8B9E-4C07-96F6-3F83C2E88C61@codesourcery.com> (raw)
In-Reply-To: <4FDAA190.3050706@tilera.com>

On 15/06/2012, at 2:44 PM, Chris Metcalf wrote:

> On 6/14/2012 9:20 PM, Maxim Kuvyrkov wrote:
...
>> As I read it, in case of a contended lock __lll_lock_wait will reset the value of the lock to "2" before calling lll_futex_wait().  I agree that there is a timing window in which the other threads will see a value of the lock greater than "2", but the value will not get as high as hundreds or billions as it will be constantly reset to "2" in atomic_exchange in lll_lock_wait().
>> 
>> I do not see how threads will get into a busywait state, though.  Would you please elaborate on that?
> 
> You are correct.  I was thinking the that the while loop had a cmpxchg, but
> since it's just a straight-up exchange, the flow will be something like:
> 
> - Fail to initially call lll_futex_wait() if the lock is contended
> - Fall through to while loop
> - Spin as long as the lock is contended enough that *futex > 2
> - Enter futex_wait
> 
> So a little busy under high contention, but probably settles out reasonably
> well.

Exactly.  I will include the above scenario in the comment to make it more transparent.

Thank you,

--
Maxim Kuvyrkov
CodeSourcery / Mentor Graphics

  reply	other threads:[~2012-06-15  2:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-14  5:04 Maxim Kuvyrkov
2012-06-14 12:39 ` Chris Metcalf
2012-06-15  1:21   ` Maxim Kuvyrkov
2012-06-15  2:44     ` Chris Metcalf
2012-06-15  2:50       ` Maxim Kuvyrkov [this message]
2012-06-27 21:45         ` Maxim Kuvyrkov
2012-06-28 17:30           ` Chris Metcalf
2012-07-06 19:42             ` Tom de Vries
2012-08-14  4:00               ` Maxim Kuvyrkov
2012-08-14 19:33                 ` Chris Metcalf
2012-08-14 21:30                   ` Maxim Kuvyrkov
2012-08-14 21:40                     ` Joseph S. Myers

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=C8A2E1C0-8B9E-4C07-96F6-3F83C2E88C61@codesourcery.com \
    --to=maxim@codesourcery.com \
    --cc=cmetcalf@tilera.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=vries@codesourcery.com \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).