This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: What *is* the API for sched_getaffinity? Should sched_getaffinity always succeed when using cpu_set_t?


On 07/18/2013 05:23 AM, Samuel Thibault wrote:
> Carlos O'Donell, le Thu 18 Jul 2013 05:14:45 -0400, a écrit :
>> Either way the question remains:
>>
>> (1) Should glibc's sched_getaffinity never fail?
>>
>> or
>>
>> (2) Should glibc's sched_getaffinity fail with EINVAL when the size
>> of the cpu set is smaller than the size of the affinity mask for
>> all possible cpus?
>>
>> I believe that a call to sched_getaffinity should not fail.
>>
>> What do you think?
> 
> Ideally there would have never been a static cpu_set_t type, so the
> answer would have been 2). It happens that the hwloc library, in use in
> a lot of MPI implementations and batch schedulers, and thus does care
> a lot about lots of CPUs, currently depends on 2), because we had seen
> that documented in RedHat. We will probably migrate to using "possible"
> instead, but it will take time to get propagated to systems, not surely
> faster than a newer glibc that breaks it.

I agree that ideally there should not have been a static cpu_set_t.

I strongly recommend all users use dynamic cpu sets and sysconf to
determine the needed size.

If your cpus are already online you should always use 
sysconf (_SC_NPROCESSORS_ONLN) to compute the size of the required
set and pass that to sched_getaffinity. The bug is that today this
returns EINVAL, but once we fix it, it will never fail to return
an affinity mask of at least that size.

I lament that the Red Hat man page said what it said, and the 
example code showing the use of EINVAL has been removed.

Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]