mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [PATCH 1/2] let them spin
Date: Sun, 30 Aug 2015 13:02:39 -0400	[thread overview]
Message-ID: <20150830170239.GM7833@brightrain.aerifal.cx> (raw)
In-Reply-To: <1440924113.693.18.camel@inria.fr>

On Sun, Aug 30, 2015 at 10:41:53AM +0200, Jens Gustedt wrote:
> > > So the difference isn't dramatic, just one order of magnitude and
> > > everybody gets his chance. These chances are not equal, sure, but
> > > NEVER in capitals is certainly a big word.
> > 
> > Try this: on a machine with at least 3 physical cores, 3 threads
> > hammer on the same lock, counting the number of times they succeed in
> > taking it. Once any one thread has taken it at least 10 million times
> > or so, stop and print the counts. With your spin strategy I would
> > expect to see 2 threads with counts near 10 million and one thread
> > with a count in the hundreds or less, maybe even a single-digit count.
> > With the current behavior (never spinning if there's a waiter) I would
> > expect all 3 counts to be similar.
> 
> The setting that you describe is really a pathological one, where the
> threads don't do any work between taking the lock and releasing it. Do
> I understand that correctly?

If you're using locks to implement fake greater-than-wordsize atomics
then it's the normal case, not a pathological one. You have
(effectively) things like:

	_Atomic long double x;
	__lock(global_lock);
	x++;
	__unlock(global_lock);

For a more realistic example, consider atomic CAS on a linked-list
prev/next pointer pair.

Rich


  reply	other threads:[~2015-08-30 17:02 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-29  8:50 Jens Gustedt
2015-08-29 17:16 ` Rich Felker
2015-08-29 19:38   ` Jens Gustedt
2015-08-30  0:39     ` Rich Felker
2015-08-30  8:41       ` Jens Gustedt
2015-08-30 17:02         ` Rich Felker [this message]
2015-08-30 21:48           ` Jens Gustedt

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=20150830170239.GM7833@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).