This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] aarch64: Optimized implementation of pthread_spin_lock and unlock
- From: Szabolcs Nagy <Szabolcs dot Nagy at arm dot com>
- To: Andrew Pinski <pinskia at gmail dot com>, Xuelei Zhang <zhangxuelei4 at huawei dot com>
- Cc: nd <nd at arm dot com>, GNU C Library <libc-alpha at sourceware dot org>, Wilco Dijkstra <Wilco dot Dijkstra at arm dot com>, Siddhesh Poyarekar <siddhesh at gotplt dot org>, "jiangyikun at huawei dot com" <jiangyikun at huawei dot com>, "yikunkero at gmail dot com" <yikunkero at gmail dot com>
- Date: Tue, 29 Oct 2019 10:31:47 +0000
- Subject: Re: [PATCH] aarch64: Optimized implementation of pthread_spin_lock and unlock
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/MFHzuZg56AfzvG5uyzMasTg62HZtobJBEOqUeV1OjQ=; b=fSwnml63tdDoQV22skMhW7/mxuGOBLE8iSm7zG1uvle+1Vm79PET0CD4+nu+1Kd7h1P57TbrjXc1TOy/mtZ2ll2e6iFSclTtZcnWFwFoNNiOSktnrnrYA3W3TFJIpeVJZb8mFInah8dRgarsos22zS9Q7djGaDD7Wtu7C/levuq550s0VpLsPISwSXJYmgU3ZtJgbvbkrbj0F9CedI8wyhzW2Jg0OSP3bqWimDhYJ0I5e+xF9gOR5LPx/yMchNHnfLX8426xKlO101EI7GtsdwSamyBTonGSvCAQ6YufucAH/Ev0fiqg6jivGd/adnvWzi6Xoa71D/K39AMGH1LlSA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aFnD77yiC85RE83DuM/gIAlt/qWuEntKZE1F9c/j8tD/I972jDdTLIMiaKOAhs2gpRtjuyeAanwAd9DWrLhZgTNA0GmWqzsb9rPx82pYboi6KIa883P5KbNrm51rPVVP0ApvT+CV6eDN6trO4VMzMP2ZnTZt5yj+FQMvXCpuvXXXiRexhRhO2EpPF/zJmRMmFFx6CFITPqEyQwadsNuWbb+Cubw4BQPuYkojsObCDQCxJCdDcH37sN56Zi0uECNhLScrg5e4DDVJW8/t47afL2Je4mzOaptgBvxvPyMks6/TkTB8z1usADA+PS+yE/AstFpRa6eAc8jcizri9r8Ytg==
- Original-authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- References: <20191028133911.8612-1-zhangxuelei4@huawei.com> <CA+=Sn1mO8cSN3JLrAsSWDQZSLRiSyyw5_U81XWecEJk_BRstNQ@mail.gmail.com>
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.