[RFC] [PATCH] sched_getaffinity() fails with -EINVAL

Carlos O'Donell carlos@systemhalted.org
Wed Feb 17 14:12:00 GMT 2010


On Thu, Oct 29, 2009 at 11:39 PM, Sharyathi Nagesh <sharyath@in.ibm.com> wrote:
> ========================================================================
> Explanation:
>        We are observing that ltp test case getcpu01.c is failing in some of
> the machines. In the test case: system call to sched_getaffinity() fails.
> Linux kernel is giving EINVAL on call to sched_getaffinity().

Sharyathi,

You should note the following things:

(a) The GLIBC implementation is correct, but difficult to use because
the static size of a cpu_set_t doesn't match the kernel value. The
call to sched_getaffinity is documented as returning EINVAL if
cpusetsize is smaller than the size of the affinity mask used by the
kernel. In this case you could use CPU_ALLOC to increase the size of
the data pointed to by a cpu_set_t and call sched_getaffinity again.

(b) It is more convenient if the default size of a cpu_set_t matches the kernel.

(c) If the user cpu_set_t is larger than the kernel cpumask_var_t, the
kernel ignores the additional user bits.

> 2009-10-30  Sharyathi Nagesh  <sharyathi@in.ibm.com>
>
>        * bits/sched.c (__CPU_SETSIZE): Size of the cpu_set_t data structure
> is changed to        4096 bits from earlier 1024 bits to reflect changes in
> the Linux kernel.

It's "bits/sched.h" not "bit/sched.c."

Your ChangeLog lines *must* wrap at 80 characters or less.

With the above changes I think this email and patch is OK to go to libc-alpha.

Cheers,
Carlos.



More information about the Libc-help mailing list