Re: [PATCH] Improve spinlock inline assembly for x86.

From: Andres Freund <andres(at)anarazel(dot)de>
To: Robert Haas <robertmhaas(at)gmail(dot)com>, Andreas Seltenreich <seltenreich(at)gmx(dot)de>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] Improve spinlock inline assembly for x86.
Date: 2016-01-18 21:04:01
Message-ID: 417894F3-1BB8-4737-9BBB-2ACF53AAFD6B@anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On January 18, 2016 7:27:59 PM GMT+01:00, Robert Haas <robertmhaas(at)gmail(dot)com> wrote:
>On Sun, Jan 17, 2016 at 6:38 AM, Andreas Seltenreich
><seltenreich(at)gmx(dot)de> wrote:
>> I'm currently experimenting with just-in-time compilation using
>libfirm.
>> While discussing issues with its developers, it was pointed out to me
>> that our spinlock inline assembly is less than optimal. Attached is
>a
>> patch that addresses this.
>>
>> ,----
>> | Remove the LOCK prefix from the XCHG instruction. Locking is
>implicit
>> | with XCHG and the prefix wastes a byte. Also remove the "cc"
>register
>> | from the clobber list as the XCHG instruction does not modify any
>flags.
>> |
>> | Reported by Christoph Mallon.
>> `----
>
>I did a Google search and everybody seems to agree that the LOCK
>prefix is redundant. I found a source agreeing with the idea that it
>doesn't clobber registers, too:
>
>http://www.oopweb.com/Assembly/Documents/ArtOfAssembly/Volume/Chapter_6/CH06-1.html#HEADING1-85
>
>So I guess it would be safe to change this. Scares me slightly,
>though.

Clobbers IIRC are implicit on x86 anyway. Rather doubt that the space for the prefix makes any sorry of practical difference, but there indeed seems no reason to have it.

Andres

---
Please excuse brevity and formatting - I am writing this on my mobile phone.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2016-01-18 21:04:04 Re: Truncating/vacuuming relations on full tablespaces
Previous Message Bruce Momjian 2016-01-18 21:02:57 Re: Fwd: [JDBC] Re: 9.4-1207 behaves differently with server side prepared statements compared to 9.2-1102