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 4/8] determine the existence of private futexes at the first thread creation
Date: Fri, 23 Jun 2017 20:53:48 -0400	[thread overview]
Message-ID: <20170624005348.GS1627@brightrain.aerifal.cx> (raw)
In-Reply-To: <20170624014220.4e52f616@inria.fr>

On Sat, Jun 24, 2017 at 01:42:20AM +0200, Jens Gustedt wrote:
> Hello Rich,
> 
> On Fri, 23 Jun 2017 18:08:23 -0400 Rich Felker <dalias@libc.org> wrote:
> 
> > On Fri, Jun 23, 2017 at 11:48:25PM +0200, Jens Gustedt wrote:
> > > Hello Rich,
> > > 
> > > On Fri, 23 Jun 2017 13:05:35 -0400 Rich Felker <dalias@libc.org>
> > > wrote: 
> > > > This was intentional, the idea being that a 100% predictable
> > > > branch in a path where a syscall is being made anyway is much
> > > > less expensive than a GOT address load that gets hoisted all the
> > > > way to the top of the function and affects even code paths that
> > > > don't need to make the syscall. Whether it was a choice that
> > > > makes sense overall, I'm not sure, but that was the intent.  
> > > 
> > > So if we can avoid going through GOT, this would be better?
> > > I'd just add ATTR_LIBC_VISIBILITY to the variable, and then this
> > > should go away the same way as it is done for the libc object.  
> > 
> > It's not going through the GOT that's costly, but actually getting the
> > GOT address, which is used for both accesses through the GOT and
> > GOT-relative addressing. On several archs including i386, PC-relative
> > addressing is not directly available and requires hacks to load the PC
> > into a GPR, and these usually take some cycles themselves and spill
> > out of the free call-clobbered registers so that additional stack
> > shuffling is needed.
> 
> So you are saying that when I add ATTR_LIBC_VISIBILITY
> and see something like
> 
> 	movslq	__futex_private(%rip), %rsi

i386 does not have (%rip). x86_64 is one of the archs with very
efficient PC-relative addressing.

> What would you think of a patch that just cleans up the 128 vs
> FUTEX_PRIVATE issue? Just to improve readability?

That seems like a good thing. Regarding the mutex flag, I thought some
places we depended on the 128 shared mutex flag being the inverse of
the FUTEX_PRIVATE flag (so ^128 translates between them); if this is
the case, do you have an elegant way to make it work?

> Also there is this missing volatile in __get_locale.

Nice catch.

Rich


  reply	other threads:[~2017-06-24  0:53 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-23 14:38 [PATCH 0/8] the new __lock and follow up patches Jens Gustedt
2017-06-16  7:11 ` [PATCH 1/8] (V2) a new lock algorithm with lock value and CS counts in the same atomic int Jens Gustedt
2017-12-20 21:58   ` Rich Felker
2017-12-21 11:06     ` Jens Gustedt
2017-12-21 23:34       ` Rich Felker
2018-01-03 14:08         ` automated coding style Jens Gustedt
2018-01-11  4:41           ` Samuel Holland
2018-01-11  8:28             ` Jens Gustedt
2017-06-20 13:25 ` [PATCH 3/8] revise the definition of multiple basic locks in the code Jens Gustedt
2017-06-20 19:08 ` [PATCH 6/8] use the new lock algorithm for malloc Jens Gustedt
2017-06-23 15:01   ` Jens Gustedt
2017-06-20 19:41 ` [PATCH 2/8] consistently use the LOCK an UNLOCK macros Jens Gustedt
2017-06-20 19:44 ` [PATCH 5/8] separate the fast parts of __lock and __unlock into a .h file that may be used by other TU Jens Gustedt
2017-06-20 20:35 ` [PATCH 4/8] determine the existence of private futexes at the first thread creation Jens Gustedt
2017-06-23 17:05   ` Rich Felker
2017-06-23 17:16     ` Jens Gustedt
2017-06-23 21:48     ` Jens Gustedt
2017-06-23 22:08       ` Rich Felker
2017-06-23 23:42         ` Jens Gustedt
2017-06-24  0:53           ` Rich Felker [this message]
2017-06-24  8:00             ` Jens Gustedt
2017-06-24 10:12               ` flag 128 Jens Gustedt
2017-06-24 22:28                 ` Rich Felker
2017-06-24 22:23   ` [PATCH 4/8] determine the existence of private futexes at the first thread creation Rich Felker
2017-06-22 21:17 ` [PATCH 7/8] implement __unlock_requeue Jens Gustedt
2017-06-22 21:42 ` [PATCH 8/8] implement the local lock for conditions with __lock & Co Jens Gustedt
2017-06-23 14:57 ` [PATCH 0/8] the new __lock and follow up patches 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=20170624005348.GS1627@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).