From: Florian Weimer <fweimer-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: "Michael Kerrisk (man-pages)"
<mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
Carlos O'Donell <carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
Roland McGrath <roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org>
Cc: KOSAKI Motohiro
<kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
libc-alpha <libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org>,
linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t?
Date: Wed, 22 Jul 2015 18:02:15 +0200 [thread overview]
Message-ID: <55AFBE87.1040006@redhat.com> (raw)
In-Reply-To: <55AE5F33.3080105-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
On 07/21/2015 05:03 PM, Michael Kerrisk (man-pages) wrote:
> Hello Florian,
>
> Thanks for your comments, and sorry for the delayed follow-up.
>
> On 07/01/2015 02:37 PM, Florian Weimer wrote:
>> On 06/26/2015 10:05 PM, Michael Kerrisk (man-pages) wrote:
>>
>>> +.SS Handling systems with more than 1024 CPUs
>>> +The
>>> +.I cpu_set_t
>>> +data type used by glibc has a fixed size of 128 bytes,
>>> +meaning that the maximum CPU number that can be represented is 1023.
>>> +.\" FIXME . See https://sourceware.org/bugzilla/show_bug.cgi?id=15630
>>> +.\" and https://sourceware.org/ml/libc-alpha/2013-07/msg00288.html
>>> +If the system has more than 1024 CPUs, then calls of the form:
>>> +
>>> + sched_getaffinity(pid, sizeof(cpu_set_t), &mask);
>>> +
>>> +will fail with the error
>>> +.BR EINVAL ,
>>> +the error produced by the underlying system call for the case where the
>>> +.I mask
>>> +size specified in
>>> +.I cpusetsize
>>> +is smaller than the size of the affinity mask used by the kernel.
>>
>> I think it is best to leave this as unspecified as possible. Kernel
>> behavior already changed once, and I can imagine it changing again.
>
> Hmmm. Something needs to be said about what the kernel is doing though.
> Otherwise, it's hard to make sense of this subsection. Did you have a
> suggested rewording that removes the piece you find problematic?
What about this?
“If the kernel affinity mask is larger than 1024 then
…
is smaller than the size of the affinity mask used by the kernel.
Depending on the system CPU topology, the kernel affinity mask can
be substantially larger than the number of active CPUs in the system.
”
I.e., make clear that the size of the mask can be quite different from
the CPU count.
> Handling systems with more than 1024 CPUs
> The underlying system calls (which represent CPU masks as bit
> masks of type unsigned long *) impose no restriction on the
> size of the CPU mask. However, the cpu_set_t data type used by
> glibc has a fixed size of 128 bytes, meaning that the maximum
> CPU number that can be represented is 1023. If the system has
> more than 1024 CPUs, then calls of the form:
>
> sched_getaffinity(pid, sizeof(cpu_set_t), &mask);
>
> will fail with the error EINVAL, the error produced by the
> underlying system call for the case where the mask size speci‐
> fied in cpusetsize is smaller than the size of the affinity
> mask used by the kernel.
>
> When working on systems with more than 1024 CPUs, one must
> dynamically allocate the mask argument. Currently, the only
> way to do this is by probing for the size of the required mask
> using sched_getaffinity() calls with increasing mask sizes
> (until the call does not fail with the error EINVAL).
>
> Better?
“more than 1024 CPUs” should be “large [kernel CPU] affinity masks”
throughout.
--
Florian Weimer / Red Hat Product Security
--
To unsubscribe from this list: send the line "unsubscribe linux-man" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-07-22 16:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <51E42BFE.7000301@redhat.com>
[not found] ` <51E4A0BB.2070802@gmail.com>
[not found] ` <51E4A123.9070001@gmail.com>
[not found] ` <51E6F3ED.8000502@redhat.com>
[not found] ` <51E6F956.5050902@gmail.com>
[not found] ` <51E714DE.6060802@redhat.com>
[not found] ` <CAHGf_=oZW3kNA3V-9u+BZNs3tL3JKCsO2a0Q6f0iJzo=N4Wb8w@mail.gmail.com>
[not found] ` <51E7B205.3060905@redhat.com>
[not found] ` <20130722214335.D9AFF2C06F@topped-with-meat.com>
[not found] ` <51EDB378.8070301@redhat.com>
[not found] ` <51EDB378.8070301-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-06-26 14:28 ` What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t? Michael Kerrisk (man-pages)
[not found] ` <558D6171.1060901-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-26 20:05 ` Michael Kerrisk (man-pages)
[not found] ` <558DB0A0.2040707-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-06-29 21:40 ` Tolga Dalman
[not found] ` <5591BB55.5080605-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org>
2015-07-21 15:03 ` Michael Kerrisk (man-pages)
2015-07-01 12:37 ` Florian Weimer
[not found] ` <5593DF14.2060804-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-21 15:03 ` Michael Kerrisk (man-pages)
[not found] ` <55AE5F33.3080105-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2015-07-22 16:02 ` Florian Weimer [this message]
[not found] ` <55AFBE87.1040006-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-07-22 16:43 ` Michael Kerrisk (man-pages)
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=55AFBE87.1040006@redhat.com \
--to=fweimer-h+wxahxf7alqt0dzr+alfa@public.gmane.org \
--cc=carlos-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=kosaki.motohiro-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=libc-alpha-9JcytcrH/bA+uJoB2kUjGw@public.gmane.org \
--cc=linux-man-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=mtk.manpages-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=roland-/Z5OmTQCD9xF6kxbq+BtvQ@public.gmane.org \
/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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.