This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] aarch64: Optimized implementation of pthread_spin_lock and unlock


On 28/10/2019 17:53, Andrew Pinski wrote:
> On Mon, Oct 28, 2019 at 6:39 AM Xuelei Zhang <zhangxuelei4@huawei.com> wrote:
>> +ENTRY (pthread_spin_unlock)
>> +       DELOUSE (0)
>> +       stlr    wzr, [x0]
>> +       mov     w0, #0x0
> 
> Actually the C version of pthread_spin_unlock is implemented this way
> already and provides exactly this same assembly.
> Why do you need an assembly version?

if lock is in asm, then unlock must be in asm too.

we don't want to reason about synchronization
between asm and c code as their memory model is
defined differently and we don't want to rely
on a particular implementation in the compiler.

and the generic c code may change independently
(e.g. spin_unlock used to be barrier + store
but changed at some point, such change can easily
break the synchronization without us noticing)

i'd prefer to improve the generic c code if
possible instead of using asm.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]