This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH v2] nptl: optimize cancelstate and canceltype changing
- From: Richard Henderson <rth at twiddle dot net>
- To: Alexander Fyodorov <halcy at yandex dot ru>, libc-alpha at sourceware dot org, Carlos O'Donell <carlos at redhat dot com>, David Miller <davem at davemloft dot net>
- Date: Sun, 15 Jun 2014 12:39:19 -0700
- Subject: Re: [PATCH v2] nptl: optimize cancelstate and canceltype changing
- Authentication-results: sourceware.org; auth=none
- References: <180951402831608 at web26g dot yandex dot ru>
On 06/15/2014 04:26 AM, Alexander Fyodorov wrote:
> Changes since v1:
> 1) Added a benchtest for pthread_setcanceltype().
> 2) Defined atomic_write() macro for old SPARC processors.
> atomic_write() macro is needed because on some architectures there is no hardware support for atomic compare-and-swap, and it is implemented via spinlock. And writing to variables that are accessed with such compare-and-swap must be done under the same spinlock to avoid the race leading to the lost write.
> Dave, could you check my implementation of atomic_write()? I don't have SPARC...
What has lack of compare-and-swap got to do with write?
Certainly sparc stores (of not larger than word size) are atomic. One might
even be able to produce a 64-bit atomic store with std or the fpu; one can't
tell what size you're actually after with this macro.
Certainly, with new enough gcc one ought to use the __atomic_store builtin, but
a plain c store should suffice as a fallback.