|
Message-ID: <1440971280.693.25.camel@inria.fr>
Date: Sun, 30 Aug 2015 23:48:00 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: [PATCH 1/2] let them spin
Am Sonntag, den 30.08.2015, 13:02 -0400 schrieb Rich Felker:
> 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);
you probably just mean "volatile" instead of "_Atomic"?
In any case, this already has a memory write inside the critical
section, that is not nothing compared to the fast path of the
__lock/__unlock operation.
> For a more realistic example, consider atomic CAS on a linked-list
> prev/next pointer pair.
So that one would be similar to the different tests I did for
<stdatomic.h>. So far I wasn't able to observe your "NEVER" case, and
I did a substantial number of runs over the last weeks.
Jens
--
:: INRIA Nancy Grand Est ::: Camus ::::::: ICube/ICPS :::
:: ::::::::::::::: office Strasbourg : +33 368854536 ::
:: :::::::::::::::::::::: gsm France : +33 651400183 ::
:: ::::::::::::::: gsm international : +49 15737185122 ::
:: http://icube-icps.unistra.fr/index.php/Jens_Gustedt ::
Download attachment "signature.asc" of type "application/pgp-signature" (182 bytes)
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.