Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date: Wed, 13 Aug 2014 09:19:05 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: Explaining cond var destroy [Re: C threads, v3.0]

Am Mittwoch, den 13.08.2014, 08:43 +0200 schrieb Jens Gustedt:
> Am Dienstag, den 12.08.2014, 17:18 -0400 schrieb Rich Felker:
> > On Tue, Aug 12, 2014 at 09:09:21PM +0200, Jens Gustedt wrote:
> > > Rich,
> > > thanks a lot for looking into the code.
> > > 
> > > Am Dienstag, den 12.08.2014, 12:01 -0400 schrieb Rich Felker:
> > > > As far as I can tell, the only thing that's saving you from sending
> > > > futex wakes after free is that you're just using spinlocks.
> > > 
> > > No, I don't think so. These protect critical sections at the beginning
> > > of the cnd_t calls. The cnd_*wait calls hold the mutex at that time
> > > anyhow, so even if these would be implemented with mutexes (an extra
> > > one per cnd_t to protect the critical section) this wouldn't cause
> > > late wakes, I think.
> > 
> > I was talking about the unref-and-free code that's using spinlocks.
> 
> I don't understand, the unref-and-free code doesn't use spinlocks. It
> just uses an atomic_fetch_sub of 1 to determine if it is the last
> user. If it is not, it does nothing and returns.
> 
> (This is indeed supposing that atomic_fetch_sub is "lock-free" in the
> sense of the C standard, which basically means that it has no
> observable state from a signal handler. All architectures I know of
> have that property, but my knowledge is limited.)

ah, perhaps you meant that the unref-and-free was done while holding
the spinlock? Maybe in the version that I posted this was the
case. That was a bug that I have now corrected.

I also have added an initial check for the wakers to see if they have
anything to do before they go into the spinlock. This should basically
solve the herd-doing-wakeup problem, since as soon as all waiters are
considered to be unblocked, wakers will return immediately without
spinning.

Jens

-- 
:: INRIA Nancy Grand Est ::: AlGorille ::: 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" (199 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.