[PATCH 08/11] nptl: Move cancel state out of cancelhandling
Florian Weimer
fweimer@redhat.com
Thu May 27 16:48:16 GMT 2021
* Adhemerval Zanella:
> On 26/05/2021 15:20, Florian Weimer wrote:
>> * Adhemerval Zanella via Libc-alpha:
>>
>>> diff --git a/nptl/descr.h b/nptl/descr.h
>>> index a120365f88..a3084fdf60 100644
>>> --- a/nptl/descr.h
>>> +++ b/nptl/descr.h
>>
>>> @@ -407,6 +401,10 @@ struct pthread
>>> /* Used on strsignal. */
>>> struct tls_internal_t tls_state;
>>>
>>> + /* Thread cancel state (PTHREAD_CANCEL_ENABLE or
>>> + PTHREAD_CANCEL_DISABLE). */
>>> + unsigned char cancelstate;
>>
>> You could move this into the padding after the c11 flag, I think.
>
> Right, I moved to below c11. What kind of constraint we have for the
> 'struct pthread' regarding its internal member layout? We have a couple
> of unused fields and might be good to clean them up.
The sanitizers depend on the size to derive the TLS memory area from the
thread pointer.
>> I think there is an implied dependency on PTHREAD_CANCEL_ENABLE == 0 in
>> __tls_init_tp and somewhere in pthread_create. Maybe add a static
>> assert for PTHREAD_CANCEL_ENABLE == 0?
>
> I think it would be better to add an initialization on __tls_init_tp,
> similar to get_cached_stack. It would be better if we consolidate
> the 'struct pthread' initialization in a common place.
We depend a lot on zero initialization, though. Maybe it would be
better to use memset in get_cached_stack. Unrelated change, of course.
Thanks,
Florian
More information about the Libc-alpha
mailing list