[PATCH v5 3/3] nptl: Remove INVALID_TD_P
Florian Weimer
fweimer@redhat.com
Wed Dec 3 17:57:29 GMT 2025
* Adhemerval Zanella Netto:
> On 28/11/25 14:20, Florian Weimer wrote:
>> * Adhemerval Zanella:
>>
>>> diff --git a/sysdeps/nptl/pthreadP.h b/sysdeps/nptl/pthreadP.h
>>> index b6a6d8f18d..2ec0a3fe96 100644
>>> --- a/sysdeps/nptl/pthreadP.h
>>> +++ b/sysdeps/nptl/pthreadP.h
>>> @@ -217,6 +217,11 @@ libc_hidden_proto (__pthread_current_priority)
>>> nothing. And if the test triggers the thread descriptor is
>>> guaranteed to be invalid. */
>>> #define INVALID_TD_P(pd) __builtin_expect ((pd)->tid <= 0, 0)
>>> +static inline bool
>>> +__pthread_descriptor_valid (struct pthread *pd)
>>> +{
>>> + return atomic_load_relaxed (&pd->joinstate) != THREAD_STATE_EXITED;
>>> +}
>>
>> Why not included THREAD_STATE_EXITING as well? At that point, the TID
>> can turn invalid any moment.
>
> It will require to add another state and add some extra synchronization
> besides that the kernel does by setting the 'joinstate' to 0. For the
> function that use INVALID_TD_P this seems an extra complexity without
> straightforward gains.
Okay, I don't have a strong opinion here.
Thanks,
Florian
More information about the Libc-alpha
mailing list