This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Use __syscall_ulong_t for __cpu_mask
- From: "H.J. Lu" <hjl dot tools at gmail dot com>
- To: "Carlos O'Donell" <carlos at redhat dot com>
- Cc: GNU C Library <libc-alpha at sourceware dot org>
- Date: Tue, 1 Dec 2015 10:24:01 -0800
- Subject: Re: [PATCH] Use __syscall_ulong_t for __cpu_mask
- Authentication-results: sourceware.org; auth=none
- References: <1448909195-12575-1-git-send-email-hjl dot tools at gmail dot com> <565DC5B6 dot 8000102 at redhat dot com> <CAMe9rOo-wky+ExS_W5XmvkhauHhkyNK0cHsAQHBOh652=JsZRA at mail dot gmail dot com> <565DCFF6 dot 1080402 at redhat dot com> <CAMe9rOoSC_OsLdBFZ8Nqh6gv8c3ktCZtAUDULWothoa-TMv0Vw at mail dot gmail dot com> <CAMe9rOqgacVWOgUV_xZiCMehvW_Og2Y+k1DnvKXyyA2yAxuUwQ at mail dot gmail dot com> <565DE447 dot 8070209 at redhat dot com>
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.
--
H.J.