mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Jens Gustedt <jens.gustedt@inria.fr>
To: musl@lists.openwall.com
Subject: Re: [PATCH] a new lock algorithm with lock value and CS counts in the same atomic int
Date: Sun, 18 Jun 2017 21:32:09 +0200	[thread overview]
Message-ID: <20170618213209.260ae8e4@inria.fr> (raw)
In-Reply-To: <20170618160459.GW1627@brightrain.aerifal.cx>

[-- Attachment #1: Type: text/plain, Size: 1697 bytes --]

Hello Rich,

On Sun, 18 Jun 2017 12:04:59 -0400 Rich Felker <dalias@libc.org> wrote:

> > > Is there a reason __wait doesn't work?  
> > 
> > __wait doesn't fit here at all, for instance it manipulates a
> > separate int with waiters count.  
> 
> It accepts a null pointer for the waiters count, so that it can be
> used in contexts with or without one. Any cost of the additional
> conditional branches is dominated by syscall time.

Looking into it, I don't agree with you, Rich. Even with waiters set
to 0 it would to 100 spins before going into the syscall. This is much
of a waste, here, because we are just comming out of a spin (at the
first iteration) or we did spin around as long as the value was
positive.

I don't see why the cost of 100 spins would be dominated by the
syscall. If I remember correctly, the benchmarks that I made showed
about 10 memory operations for an unsuccessful syscall. This is why
the magic number for the initial spin is set to 10.

It might be benefitial to do a_spin for a while, if we know that CS
that are protected by this lock are really short, just some
cycles. But 100 is a far too big number, and in my benchmarks I found
not much indication of a benefit for it.

If we want code sharing with the rest of musl (which we should) I like
Alexander's idea of a __futexwait inline function much better.


Thanks
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 ::

[-- Attachment #2: Digitale Signatur von OpenPGP --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

  parent reply	other threads:[~2017-06-18 19:32 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-16  7:11 Jens Gustedt
2017-06-18 10:01 ` Alexander Monakov
2017-06-18 11:10   ` Jens Gustedt
2017-06-18 11:49     ` Alexander Monakov
2017-06-18 14:45       ` Rich Felker
2017-06-18 14:58         ` Alexander Monakov
2017-06-18 13:40 ` Alexander Monakov
2017-06-18 14:53   ` Rich Felker
2017-06-18 15:05     ` Alexander Monakov
2017-06-18 16:04       ` Rich Felker
2017-06-18 17:31         ` Jens Gustedt
2017-06-18 19:32         ` Jens Gustedt [this message]
2017-06-18 20:20           ` Rich Felker
2017-06-18 20:38             ` Alexander Monakov
2017-06-18 17:40     ` Jens Gustedt
2017-06-18 15:01 ` Rich Felker

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=20170618213209.260ae8e4@inria.fr \
    --to=jens.gustedt@inria.fr \
    --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).