mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Timo Teras <timo.teras@iki.fi>
To: musl@lists.openwall.com
Cc: rob@landley.net
Subject: Re: Proposed roadmap to 1.0
Date: Thu, 25 Jul 2013 13:29:28 +0300	[thread overview]
Message-ID: <20130725132928.22f5c40c@vostro> (raw)
In-Reply-To: <1374691013.3031.6@driftwood>

On Wed, 24 Jul 2013 13:36:53 -0500
Rob Landley <rob@landley.net> wrote:

> On 07/17/2013 11:02:05 AM, Rich Felker wrote:
> > > - Affinity/cpuset interfaces.
> > 
> > Last time I started working on this, I got sick of it before I got
> > very far. There are just so many tedious macros/inline-functions to
> > implement. I was also frustrated with having to put so much code in
> > a public header. For this, I'd really like some help on both:
> > 
> > - ideas for making it less hideous, and
> > - actually writing it out.
> 
> For toybox I ignored the glibc interfaces and just used the raw  
> syscall, manipulating the arguments myself with bit shifts. Let's
> see...
> 
> Wow the man 3 CPU_SET macros are crazy. Very first one, CPU_ZERO()
> does not specify the size of the array. So how does it determine it?
> It's gotta be getting it from cpu_set_t which is defined in  
> /usr/include/*/bits/sched.h:
> 
>    /* Data structure to describe CPU mask.  */
>    typedef struct
>    {
>      __cpu_mask __bits[__CPU_SETSIZE / __NCPUBITS];
>    } cpu_set_t;
> 
> So what's _NCPUBITS?
> 
>    /* Size definition for CPU sets.  */
>    # define __CPU_SETSIZE  1024
>    # define __NCPUBITS     (8 * sizeof (__cpu_mask))
> 
>    /* Type for array elements in 'cpu_set_t'.  */
>    typedef unsigned long int __cpu_mask;
> 
> So... it's hardwired to 1024 cpus.
> 
> I don't think there _is_ a way to make this non-ugly. What actually  
> uses this?

Seems also many SMP-aware programs use sched_getaffinity to figure out
how many threads to launch. Including, but not limited to, util-linux
(nproc) and gccgo. Most should autodetect this, but gccgo seems to just
unconditionally use it.

Speaking of gccgo, it seems that gcc 4.8.1 without any changes does not
compile with musl due to:
- libgo/mksysinfo.sh: conflicting kernel and libc #includes
- libgo/runtime/getncpu-linux.c: uses sched_getaffinity + cpu_set_t
- libgo/runtime/proc.c: uses make/swap/getcontext, and needs configure
  to detect if TLS segment register (fs/gs on x86) is part of the
  context or not

The first two can be patched easily. But lack of *context is a stopper.
I think I'll need the *context for few other projects as well...

- Timo


  parent reply	other threads:[~2013-07-25 10:29 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-29 23:50 Rich Felker
2013-06-30  2:53 ` Rob Landley
2013-06-30  3:01   ` Rich Felker
2013-06-30  5:20 ` Isaac
2013-06-30  5:34   ` Rich Felker
2013-06-30  6:42     ` Isaac
2013-06-30  7:21       ` Justin Cormack
2013-06-30 12:02         ` Rich Felker
2013-07-04 18:13         ` Rob Landley
2013-07-07 20:25           ` Isaac
2013-07-04 18:10       ` Rob Landley
2013-07-07 20:30         ` Isaac
2013-06-30  9:24     ` Rob Landley
2013-06-30 10:45     ` Szabolcs Nagy
2013-06-30 21:29       ` Luca Barbato
2013-07-05 15:12   ` Rob Landley
2013-06-30  5:49 ` Strake
2013-07-17 16:02 ` Rich Felker
2013-07-24 18:36   ` Rob Landley
2013-07-24 19:47     ` Rich Felker
2013-07-25  7:25       ` Daniel Cegiełka
2013-07-25  7:40         ` Rich Felker
2013-07-27  5:30       ` Rob Landley
2013-07-25 10:29     ` Timo Teras [this message]
2013-07-24 14:14 ` orc
2013-07-24 14:42   ` Rich Felker
2013-07-24 15:29     ` orc
2013-07-24 16:04       ` Rich Felker
2013-07-24 16:25         ` orc
2013-07-24 19:41           ` 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=20130725132928.22f5c40c@vostro \
    --to=timo.teras@iki.fi \
    --cc=musl@lists.openwall.com \
    --cc=rob@landley.net \
    /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).