[PATCH 07/11] nptl: Remove CANCELING_BITMASK

Florian Weimer fweimer@redhat.com
Wed May 26 18:02:10 GMT 2021


* Adhemerval Zanella via Libc-alpha:

> The CANCELING_BITMASK is used as an optimization to avoid sending
> the signal when pthread_cancel is called in a concurrent manner.
>
> This requires then to put both the cancellation state and type on
> a shared state (cancelhandling), since 'pthread_cancel' checks
> whether cancellation is enabled and asynchrnous to either cancel
> itself of sending the signal.
>
> It also requires handle the CANCELING_BITMASK on
> __pthread_disable_asynccancel, however this is incurs in the same
> issues described on BZ#12683: the cancellation is acting even *after*
> the syscalls returns with user visible side-effects.
>
> This patch removes this optimization and simplifies the pthread
> cancellation implementation: pthread_cancel now first check if
> cancellation is already pending and if not always send a signal
> if the target is not itself.  The SIGCANCEL handler is also simpified
> since there is not need to setup a CAS loop.

“and, if not, always sends a signal” ?

> +  int ch = atomic_load_relaxed (&self->cancelhandling);
> +  /* Cancelation not enabled, not cancelled, or already exitting.  */

Typo: exitting

The change itself looks good to me, and I agree with the direction.

Thanks,
Florian



More information about the Libc-alpha mailing list