This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] The size of CPU sets, __CPU_SETSIZE is too small
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org, liuchangsheng at inspur dot com
- Date: Fri, 5 Aug 2016 11:04:19 -0300
- Subject: Re: [PATCH] The size of CPU sets, __CPU_SETSIZE is too small
- Authentication-results: sourceware.org; auth=none
- References: <1470400682-12912-1-git-send-email-liuchangsheng@inspur.com>
It has been proposed before to increase this to different values, but
it will incur in binary compatibility issues without some versioning
tricks and we will need also to make sure this will not fail with
current supported kernel with different configured options.
Instead as stated in latest sched_setaffinity documentation you should
dynamically allocate the mask [1] using the CPU_ALLOC interface [2].
GLIBC interfaces won't trigger an error for larger set values (GLIBC
2.23) [3] and you can check on some example usage on internal GLIBC
test file sysdeps/unix/sysv/linux/tst-skeleton-affinity.c.
[1] http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html
[2] http://man7.org/linux/man-pages/man3/CPU_ALLOC.3.html
[3] https://sourceware.org/bugzilla/show_bug.cgi?id=19143
On 05/08/2016 09:38, Changsheng.Liu wrote:
> From: Changsheng Liu <liuchangsheng@inspur.com>
>
> Now the size of struct cpu_set_t is 1024 bits,
> But there are many thousands of cores in the server
> and the cpumask in the Linux Kernel has been expanded to
> 5120 bits (CONFIG_NR_CPUS=5120).
> So in this patch the size of CPU sets is expanded to 5120
> for the server that has many thousands of cores
>
> Signed-off-by: Changsheng Liu <liuchangsheng@inspur.com>
> ---
> bits/sched.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/bits/sched.h b/bits/sched.h
> index ca10569..a9ba623 100644
> --- a/bits/sched.h
> +++ b/bits/sched.h
> @@ -52,7 +52,7 @@ struct __sched_param
> #if defined _SCHED_H && !defined __cpu_set_t_defined
> # define __cpu_set_t_defined
> /* Size definition for CPU sets. */
> -# define __CPU_SETSIZE 1024
> +# define __CPU_SETSIZE 5120
> # define __NCPUBITS (8 * sizeof (__cpu_mask))
>
> /* Type for array elements in 'cpu_set_t'. */
>