[PATCH v5 3/3] nptl: Remove INVALID_TD_P
Adhemerval Zanella Netto
adhemerval.zanella@linaro.org
Tue Dec 2 17:33:09 GMT 2025
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.
>
> In the test:
>
>> +enum { nthreads = 1 };
>
> Is this deliberate? Why have an array if there is just one thread?
No, I used '1' to make it easier to debug and check the calls. I will
change to larger value.
More information about the Libc-alpha
mailing list