This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH v2] nptl: optimize cancelstate and canceltype changing
- From: Rich Felker <dalias at libc dot org>
- To: Alexander Fyodorov <halcy at yandex dot ru>
- Cc: 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 11:17:51 -0400
- 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 Sun, Jun 15, 2014 at 03:26:48PM +0400, 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.
How is this handled for atomic CAS in shared memory? IMO the only way
to do this with a spinlock is having it be accessible by all
processes, which would allow any process to deadlock all other
processes maliciously. The only solution seems to be requiring a
syscall for CAS, or (preferably) doing something like the ARM kuser
helper for CAS and refusing to do SMP on such machines.
Rich