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

Sharyathi Nagesh sharyath@in.ibm.com
Wed Feb 17 06:47:00 GMT 2010


Carlos
    Any update on this issue.
I still don't see this patch applied to mainline
Is there any chance of this patch making it into the glibc main line
Thanks
Sharyathi N


On 10/30/2009 10:09 AM, Sharyathi Nagesh wrote:
> Carlos/Bert
> Thanks for your advice.
> Here I am submitting the patch as you have suggested, please let me know
> if I have to mail it to libc mailing list (libc-alpha) or raise a
> bugzilla request.
>
> ========================================================================
> 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().
>
> -----------------------------------------------------------------------
> When I execute the test case:
>
> #include<stdio.h>
> #include<errno.h>
> #define _GNU_SOURCE
> #include<sched.h>
>
> int main()
> {
> cpu_set_t set;
> if (sched_getaffinity(0, sizeof(cpu_set_t), &set) < 0)
> printf("\n Call is failing with:%d", errno);
> }
>
>
> I get this error message
> "Call is failing with:22"
> -----------------------------------------------------------------------
> Further analysis revealed that this EINVAL error message is coming from
> this part of Linux kernel code.
>
> SYSCALL_DEFINE3(sched_getaffinity, pid_t, pid, unsigned int, len,
> unsigned long __user *, user_mask_ptr)
> {
> int ret;
> cpumask_var_t mask;
>
> if (len < cpumask_size())
> return -EINVAL; <== This is where the error messages is coming from
>
>
> cpumask_size() returns 512 when 'configure maximum number of SMP
> processors and NUMA node' option is enabled in kernel config. Since len
> is only 128 (sizeof(cpu_set_t)) system call fails with EINVAL.
> In the sense user end glibc allows only 1024 CPU bits in cpu_set_t when
> kernel can support 4096 cpus/bits. This patch is to increase the size of
> this data structure.
>
> ========================================================================
> Testing:
> There was no regression observed when tested on x86-linux-gnu box with
> older kernel. Kernel in this case was 2.6.16 and application was built
> as 32 bit.
> ========================================================================
> FSF copyright assignment
> My current FSF copy right assignment is in approved status.
> ========================================================================
> GNU Changelog
>
> 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.
>
> ========================================================================
>
> Thanks
> Yeehaw



More information about the Libc-help mailing list