From: Rob Landley <rob@landley.net>
To: musl@lists.openwall.com
Cc: musl@lists.openwall.com
Subject: Re: Proposed roadmap to 1.0
Date: Sat, 27 Jul 2013 00:30:07 -0500 [thread overview]
Message-ID: <1374903007.3031.30@driftwood> (raw)
In-Reply-To: <20130724194719.GY3249@brightrain.aerifal.cx> (from dalias@aerifal.cx on Wed Jul 24 14:47:19 2013)
On 07/24/2013 02:47:19 PM, Rich Felker wrote:
> > 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.
There are arguments in favor of it, mostly realtime and userspace power
management. That said, the only thing that _needs_ to use this stuff is
taskset, and everything else can get called _by_ taskset. Toybox
implements taskset doesn't use anything out of libc to do so: syscall
wrappers and managing its own data structures.
Still, you presumably want to build an unmodified util-linux and
busybox.
The important thing isn't what glibc does, it's what the man pages say.
I often start by implementing what the documentation says,
building/running real packages, and then submitting bug reports against
the docs.
The sched_getaffinity() and sched_setaffinity() syscall wrappers seem
obvious, and then the _S versions of the macros. Round each size up to
the next sizeof(long) bytes. That's pretty much the "should implement
this, push patches upstream to make things use 'em" level.
man 3 CPU_SET says:
CPU_ALLOC() CPU_FREE()
CPU_ALLOC_SIZE() // trivial
CPU_ZERO_S() CPU_SET_S() CPU_CLR_S() CPU_ISSET_S() CPU_COUNT_S()
CPU_AND_S() CPU_OR_S() CPU_XOR_S() CPU_EQUAL_S()
That set isn't _that_ disgusting. CPU_ALLOC_SIZE(size) is just
(((((size+7)/8)+3)/4)*4 which makes CPU_ALLOC(size) just be
malloc(CPU_ALLOC_SIZE(size)) and CPU_FREE(x) is just free(x), and then
CPU_ZERO_S(size, set) becomes memset(set, 0, size)... I've posted the
set/isset equations here before, and/or/xor are just a for loop where
CPU_AND_S(size, dest, src1, src2) is just "do {unsigned __i = size/4;
while (__i) {dest[__i] = src1[__i] && src2[__i]; __i--;} } while (0)"
or similar, for CPU_COUNT_S you can just cheat and do a bitwise loop
with isset (this ain't performance critical)...
If you're bored, you could then make the non-S versions can be macros
that call the _S versions with a hardwired CPU_SETSIZE argument, and
obviously that's #defined to 1024. But "don't use deprecated
interfaces" is also a reasonably response. (If ever there's a reason to
NOT define stuff unless you #define GNU_DAMMIT it would be the non-S
versions of these macros. #ifdef GNU_BRAIN_DAMAGE...)
It's evil, but not _that_ evil...
Rob
next prev parent reply other threads:[~2013-07-27 5:30 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 [this message]
2013-07-25 10:29 ` Timo Teras
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=1374903007.3031.30@driftwood \
--to=rob@landley.net \
--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).