Message ID | CAMe9rOqgacVWOgUV_xZiCMehvW_Og2Y+k1DnvKXyyA2yAxuUwQ@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 12/01/2015 12:07 PM, H.J. Lu wrote: >>> >> What exactly was the failure mode you saw in bug 19313? >>> >> >> > >> > I got >> > >> > FAIL: nptl/tst-thread-affinity-pthread >> > FAIL: nptl/tst-thread-affinity-pthread2 >> > FAIL: nptl/tst-thread-affinity-sched >> > FAIL: posix/tst-affinity >> > FAIL: posix/tst-affinity-pid >> > >> > since size 12, which isn't multiple of 8, is passed to sched_getaffinity >> > syscall. We got 12 since __cpu_mask is unsigned long, instead of >> > unsigned long long. Thanks, that explains it all. Was it really 12 or 4? I expect it was 4 on x32 and that fails because the affinity mask wants a minimum size of 8 on x86_64. > Here is a patch to add __CPU_MASK_TYPE for __cpu_mask. > Tested on x32, i686 and x86-64. OK for master? Looks good to me. This is a bit safer and I like the explicit macro which makes it easy to identify what is or is not a CPU mask. Don't forget to mark the fixed bug with target milestone 2.23 per the new bugzilla rules to auto-generate NEWS. > 0001-Add-__CPU_MASK_TYPE-for-__cpu_mask.patch > > > From 155cb1ab1dc1baca1a80f6253c473513fdcdeeac Mon Sep 17 00:00:00 2001 > From: "H.J. Lu" <hjl.tools@gmail.com> > Date: Mon, 30 Nov 2015 10:42:28 -0800 > Subject: [PATCH] Add __CPU_MASK_TYPE for __cpu_mask > > Since x86-64 and x32 use the same set of sched_XXX system call interface: > > [hjl@gnu-6 linux-stable]$ grep sched_ > arch/x86/entry/syscalls/syscall_64.tbl > 24 common sched_yield sys_sched_yield > 142 common sched_setparam sys_sched_setparam > 143 common sched_getparam sys_sched_getparam > 144 common sched_setscheduler sys_sched_setscheduler > 145 common sched_getscheduler sys_sched_getscheduler > 146 common sched_get_priority_max sys_sched_get_priority_max > 147 common sched_get_priority_min sys_sched_get_priority_min > 148 common sched_rr_get_interval sys_sched_rr_get_interval > 203 common sched_setaffinity sys_sched_setaffinity > 204 common sched_getaffinity sys_sched_getaffinity > 314 common sched_setattr sys_sched_setattr > 315 common sched_getattr sys_sched_getattr > [hjl@gnu-6 linux-stable]$ > > __cpu_mask should be unsigned long long, instead of unsigned long, for > x32. This patch adds __CPU_MASK_TYPE so that each architecture can > define the proper type for __cpu_mask. > > [BZ #19313] > * bits/typesizes.h (__CPU_MASK_TYPE): New. > * sysdeps/mach/hurd/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. > * sysdeps/nacl/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. > * sysdeps/unix/sysv/linux/alpha/bits/typesizes.h (__CPU_MASK_TYPE): > Likewise. > * sysdeps/unix/sysv/linux/generic/bits/typesizes.h (__CPU_MASK_TYPE): > Likewise. > * sysdeps/unix/sysv/linux/s390/bits/typesizes.h (__CPU_MASK_TYPE): > Likewise. > * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h (__CPU_MASK_TYPE): > Likewise. > * sysdeps/unix/sysv/linux/x86/bits/typesizes.h (__CPU_MASK_TYPE): > * sysdeps/unix/sysv/linux/bits/sched.h (__cpu_mask): Replace > unsigned long int with __CPU_MASK_TYPE. > --- > bits/typesizes.h | 1 + > sysdeps/mach/hurd/bits/typesizes.h | 1 + > sysdeps/nacl/bits/typesizes.h | 1 + > sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 1 + > sysdeps/unix/sysv/linux/bits/sched.h | 2 +- > sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 1 + > sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 1 + > sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 1 + > sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 1 + > 9 files changed, 9 insertions(+), 1 deletion(-) > > diff --git a/bits/typesizes.h b/bits/typesizes.h > index 0c1e39c..ec5853d 100644 > --- a/bits/typesizes.h > +++ b/bits/typesizes.h > @@ -59,6 +59,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > #ifdef __LP64__ > /* Tell the libc code that off_t and off64_t are actually the same type > diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h > index 970e64e..948517e 100644 > --- a/sysdeps/mach/hurd/bits/typesizes.h > +++ b/sysdeps/mach/hurd/bits/typesizes.h > @@ -59,6 +59,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > /* Number of descriptors that can fit in an `fd_set'. */ > #define __FD_SETSIZE 256 > diff --git a/sysdeps/nacl/bits/typesizes.h b/sysdeps/nacl/bits/typesizes.h > index ed1b5dc..572ff9f 100644 > --- a/sysdeps/nacl/bits/typesizes.h > +++ b/sysdeps/nacl/bits/typesizes.h > @@ -59,6 +59,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > /* All our foo64_t types match their foo_t counterparts. */ > #define __OFF_T_MATCHES_OFF64_T 1 > diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h > index b40a2c2..aa00287 100644 > --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h > +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h > @@ -58,6 +58,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > #define __FSWORD_T_TYPE __S32_TYPE > > /* Tell the libc code that off_t and off64_t are actually the same type > diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h > index ae089df..7bee1b6 100644 > --- a/sysdeps/unix/sysv/linux/bits/sched.h > +++ b/sysdeps/unix/sysv/linux/bits/sched.h > @@ -115,7 +115,7 @@ struct __sched_param > # define __NCPUBITS (8 * sizeof (__cpu_mask)) > > /* Type for array elements in 'cpu_set_t'. */ > -typedef unsigned long int __cpu_mask; > +typedef __CPU_MASK_TYPE __cpu_mask; > > /* Basic access functions. */ > # define __CPUELT(cpu) ((cpu) / __NCPUBITS) > diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h > index de98a39..22d857f 100644 > --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h > +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h > @@ -60,6 +60,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > #ifdef __LP64__ > /* Tell the libc code that off_t and off64_t are actually the same type > diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h > index 78d377c..38af120 100644 > --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h > +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h > @@ -65,6 +65,7 @@ > #endif > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > #ifdef __s390x__ > /* Tell the libc code that off_t and off64_t are actually the same type > diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h > index 2167c28..4b7cac6 100644 > --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h > +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h > @@ -59,6 +59,7 @@ > #define __SSIZE_T_TYPE __SWORD_TYPE > #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE > #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE > +#define __CPU_MASK_TYPE __ULONGWORD_TYPE > > #if defined __arch64__ || defined __sparcv9 > /* Tell the libc code that off_t and off64_t are actually the same type > diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h > index 8889bc0..f89d9d2 100644 > --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h > +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h > @@ -71,6 +71,7 @@ > #define __BLKSIZE_T_TYPE __SYSCALL_SLONG_TYPE > #define __FSID_T_TYPE struct { int __val[2]; } > #define __SSIZE_T_TYPE __SWORD_TYPE > +#define __CPU_MASK_TYPE __SYSCALL_ULONG_TYPE > > #ifdef __x86_64__ > /* Tell the libc code that off_t and off64_t are actually the same type > -- 2.5.0
On Tue, Dec 1, 2015 at 10:17 AM, Carlos O'Donell <carlos@redhat.com> wrote: > On 12/01/2015 12:07 PM, H.J. Lu wrote: >>>> >> What exactly was the failure mode you saw in bug 19313? >>>> >> >>> > >>> > I got >>> > >>> > FAIL: nptl/tst-thread-affinity-pthread >>> > FAIL: nptl/tst-thread-affinity-pthread2 >>> > FAIL: nptl/tst-thread-affinity-sched >>> > FAIL: posix/tst-affinity >>> > FAIL: posix/tst-affinity-pid >>> > >>> > since size 12, which isn't multiple of 8, is passed to sched_getaffinity >>> > syscall. We got 12 since __cpu_mask is unsigned long, instead of >>> > unsigned long long. > > Thanks, that explains it all. Was it really 12 or 4? I expect it was 4 > on x32 and that fails because the affinity mask wants a minimum size of 8 > on x86_64. It came from size_t kernel_size = CPU_ALLOC_SIZE (size); if (getaffinity (kernel_size, initial_set) < 0) { printf ("error: size %zu: getaffinity: %m\n", size); return false; } and # define __CPU_ALLOC_SIZE(count) \ ((((count) + __NCPUBITS - 1) / __NCPUBITS) * sizeof (__cpu_mask)) When size == 96, x32 got 12, instead of 16. >> Here is a patch to add __CPU_MASK_TYPE for __cpu_mask. >> Tested on x32, i686 and x86-64. OK for master? > > Looks good to me. This is a bit safer and I like the explicit macro > which makes it easy to identify what is or is not a CPU mask. > > Don't forget to mark the fixed bug with target milestone 2.23 per the > new bugzilla rules to auto-generate NEWS. Will do. Thanks.
From 155cb1ab1dc1baca1a80f6253c473513fdcdeeac Mon Sep 17 00:00:00 2001 From: "H.J. Lu" <hjl.tools@gmail.com> Date: Mon, 30 Nov 2015 10:42:28 -0800 Subject: [PATCH] Add __CPU_MASK_TYPE for __cpu_mask Since x86-64 and x32 use the same set of sched_XXX system call interface: [hjl@gnu-6 linux-stable]$ grep sched_ arch/x86/entry/syscalls/syscall_64.tbl 24 common sched_yield sys_sched_yield 142 common sched_setparam sys_sched_setparam 143 common sched_getparam sys_sched_getparam 144 common sched_setscheduler sys_sched_setscheduler 145 common sched_getscheduler sys_sched_getscheduler 146 common sched_get_priority_max sys_sched_get_priority_max 147 common sched_get_priority_min sys_sched_get_priority_min 148 common sched_rr_get_interval sys_sched_rr_get_interval 203 common sched_setaffinity sys_sched_setaffinity 204 common sched_getaffinity sys_sched_getaffinity 314 common sched_setattr sys_sched_setattr 315 common sched_getattr sys_sched_getattr [hjl@gnu-6 linux-stable]$ __cpu_mask should be unsigned long long, instead of unsigned long, for x32. This patch adds __CPU_MASK_TYPE so that each architecture can define the proper type for __cpu_mask. [BZ #19313] * bits/typesizes.h (__CPU_MASK_TYPE): New. * sysdeps/mach/hurd/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/nacl/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/unix/sysv/linux/alpha/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/unix/sysv/linux/generic/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/unix/sysv/linux/s390/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/unix/sysv/linux/sparc/bits/typesizes.h (__CPU_MASK_TYPE): Likewise. * sysdeps/unix/sysv/linux/x86/bits/typesizes.h (__CPU_MASK_TYPE): * sysdeps/unix/sysv/linux/bits/sched.h (__cpu_mask): Replace unsigned long int with __CPU_MASK_TYPE. --- bits/typesizes.h | 1 + sysdeps/mach/hurd/bits/typesizes.h | 1 + sysdeps/nacl/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/alpha/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/bits/sched.h | 2 +- sysdeps/unix/sysv/linux/generic/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/s390/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/sparc/bits/typesizes.h | 1 + sysdeps/unix/sysv/linux/x86/bits/typesizes.h | 1 + 9 files changed, 9 insertions(+), 1 deletion(-) diff --git a/bits/typesizes.h b/bits/typesizes.h index 0c1e39c..ec5853d 100644 --- a/bits/typesizes.h +++ b/bits/typesizes.h @@ -59,6 +59,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE #ifdef __LP64__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/mach/hurd/bits/typesizes.h b/sysdeps/mach/hurd/bits/typesizes.h index 970e64e..948517e 100644 --- a/sysdeps/mach/hurd/bits/typesizes.h +++ b/sysdeps/mach/hurd/bits/typesizes.h @@ -59,6 +59,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE /* Number of descriptors that can fit in an `fd_set'. */ #define __FD_SETSIZE 256 diff --git a/sysdeps/nacl/bits/typesizes.h b/sysdeps/nacl/bits/typesizes.h index ed1b5dc..572ff9f 100644 --- a/sysdeps/nacl/bits/typesizes.h +++ b/sysdeps/nacl/bits/typesizes.h @@ -59,6 +59,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE /* All our foo64_t types match their foo_t counterparts. */ #define __OFF_T_MATCHES_OFF64_T 1 diff --git a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h index b40a2c2..aa00287 100644 --- a/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/alpha/bits/typesizes.h @@ -58,6 +58,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE #define __FSWORD_T_TYPE __S32_TYPE /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h index ae089df..7bee1b6 100644 --- a/sysdeps/unix/sysv/linux/bits/sched.h +++ b/sysdeps/unix/sysv/linux/bits/sched.h @@ -115,7 +115,7 @@ struct __sched_param # define __NCPUBITS (8 * sizeof (__cpu_mask)) /* Type for array elements in 'cpu_set_t'. */ -typedef unsigned long int __cpu_mask; +typedef __CPU_MASK_TYPE __cpu_mask; /* Basic access functions. */ # define __CPUELT(cpu) ((cpu) / __NCPUBITS) diff --git a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h index de98a39..22d857f 100644 --- a/sysdeps/unix/sysv/linux/generic/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/generic/bits/typesizes.h @@ -60,6 +60,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE #ifdef __LP64__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h index 78d377c..38af120 100644 --- a/sysdeps/unix/sysv/linux/s390/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/s390/bits/typesizes.h @@ -65,6 +65,7 @@ #endif #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE #ifdef __s390x__ /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h index 2167c28..4b7cac6 100644 --- a/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/sparc/bits/typesizes.h @@ -59,6 +59,7 @@ #define __SSIZE_T_TYPE __SWORD_TYPE #define __SYSCALL_SLONG_TYPE __SLONGWORD_TYPE #define __SYSCALL_ULONG_TYPE __ULONGWORD_TYPE +#define __CPU_MASK_TYPE __ULONGWORD_TYPE #if defined __arch64__ || defined __sparcv9 /* Tell the libc code that off_t and off64_t are actually the same type diff --git a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h index 8889bc0..f89d9d2 100644 --- a/sysdeps/unix/sysv/linux/x86/bits/typesizes.h +++ b/sysdeps/unix/sysv/linux/x86/bits/typesizes.h @@ -71,6 +71,7 @@ #define __BLKSIZE_T_TYPE __SYSCALL_SLONG_TYPE #define __FSID_T_TYPE struct { int __val[2]; } #define __SSIZE_T_TYPE __SWORD_TYPE +#define __CPU_MASK_TYPE __SYSCALL_ULONG_TYPE #ifdef __x86_64__ /* Tell the libc code that off_t and off64_t are actually the same type -- 2.5.0