Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 24 Jul 2013 15:47:19 -0400
From: Rich Felker <dalias@...ifal.cx>
To: musl@...ts.openwall.com
Subject: Re: Proposed roadmap to 1.0

On Wed, Jul 24, 2013 at 01:36:53PM -0500, Rob Landley 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:

There's a new set of macros, all ending in _S, which take an
additional size argument. However the size is in bytes and it's
unclear to me how the caller is supposed to know the required
alignment (e.g. making a 3-byte set would not be valid).

>   /* 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?

That was my question about the whole affinity system in general. My
view is that it's stupid micro-management of scheduling that should be
done by the kernel, and that if the kernel's not doing a good enough
job of managing which cpu a task runs on, the kernel scheduler should
be fixed rather than adding hacks in apps.

With that said, affinity is useful for debugging certain race
conditions that are easier to hit on single-core.

Rich

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.