From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/7385 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] Use CAS instead of atomic swap to implement spinlock Date: Tue, 14 Apr 2015 19:16:27 -0400 Message-ID: <20150414231627.GR6817@brightrain.aerifal.cx> References: <1429051493-2821-1-git-send-email-amonakov@ispras.ru> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1429053404 19101 80.91.229.3 (14 Apr 2015 23:16:44 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 14 Apr 2015 23:16:44 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-7398-gllmg-musl=m.gmane.org@lists.openwall.com Wed Apr 15 01:16:43 2015 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1YiA4Q-0007qy-Ad for gllmg-musl@m.gmane.org; Wed, 15 Apr 2015 01:16:42 +0200 Original-Received: (qmail 1603 invoked by uid 550); 14 Apr 2015 23:16:40 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 1582 invoked from network); 14 Apr 2015 23:16:40 -0000 Content-Disposition: inline In-Reply-To: <1429051493-2821-1-git-send-email-amonakov@ispras.ru> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:7385 Archived-At: On Wed, Apr 15, 2015 at 01:44:53AM +0300, Alexander Monakov wrote: > This should allow spinning without constantly dirtying cache lines holding the > spinlock value. On architectures without native atomic swap, musl implement > a_swap by looping around a_cas. It won't help on x86, where all lock-prefixed ops perform both a read and a write even if they fail. But it should help in ll/sc style archs, and shouldn't hurt on x86. Rich