🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #203

Re: Performance of xchg reg,reg

#203
From: Chris M. Thomasson
Date: Sun, 18 Oct 2026 19:27
52 lines
3570 bytes
On 10/16/2026 7:50 PM, Dan Cross wrote:
> In article <11au1vu$3ks5m$2@dont-email.me>,
> Thomas Koenig <tkoenig@netcologne.de> wrote:
>> Dan Cross <cross@spitfire.i.gajendra.net> schrieb:
>>> Unfortunately, the information is spread across two sections,
>>> and they contradict.  The description in the `LOCK` prefix
>>> section in the latest version of the Intel SDM includes the text
>>> Anton quoted, while the description of `XCHG` itself makes clear
>>> that the destination operand must be a memory operand for the
>>> locking protocol to automatically apply.  Which is correct?
>>
>> What would be the meaning of LOCK with memory operands?  I can't
>> think of any.
> 
> Using the `LOCK` prefix without a destination operand that is a
> memory operand is an error, and the SDM is quite explicit about
> that.  In fact, it says that an explicit `LOCK` prefix on an
> `XCHG` a register destination operand is _not_ permitted and
> "may" generate an `#UD` exception.
> 
> But sadly, when talking about an `XCHG` _without_ an explicit
> operand, it is left ambiguous; all it says is that, "The `XCHG`
> instruction always asserts the `LOCK#` signal regardless of the
> presence or absence of the `LOCK` prefix."  Devoid of the rest
> of the surrounding context, one could interpret that to mean
> that an `XCHG` _always_ forces a bus lock, irrespective of the
> type of its desintation operand.
> 
> Why?  I have no idea; as I said, I'm in the camp of going with
> what the description of `XCHG` itself says, and not the what the
> description of the `LOCK` prefix says: that sentence is _not_
> devoid of context, and besides, there has not been a physical
> `LOCK#` signal coming out of an Intel Xeon package since
> Nehalem.

Try a LOCK RMW on memory that straddles a L2 cache line. That should 
trigger a full bus lock.




> 
> I suppose one could imagine it forcing a poor-man's barrier to
> prevent later loads from being reorderd before it (loads can't
> migrate before locked instructions).  But we've got explicit
> fence instructions for that, so I don't buy it.
> 
> I suspect that sentence is just poorly phrased.
> 
> 	- Dan C.
> 
Technical Details
Message-ID: <11b36i8$1e6f7$1@dont-email.me>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
References: <2026Oct13.104347@mips.complang.tuwien.ac.at> <11atq3a$nqi$1@reader2.panix.com> <11au1vu$3ks5m$2@dont-email.me> <11aunpn$8c6$1@reader2.panix.com>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.arch
Subject: Re: Performance of xchg reg,reg
Date: Sun, 18 Oct 2026 12:27:04 -0700
Organization: A noiseless patient Spider
Lines: 52
Message-ID: <11b36i8$1e6f7$1@dont-email.me>
References: <2026Oct13.104347@mips.complang.tuwien.ac.at>
 <11atq3a$nqi$1@reader2.panix.com> <11au1vu$3ks5m$2@dont-email.me>
 <11aunpn$8c6$1@reader2.panix.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Sun, 18 Oct 2026 19:27:05 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="1513959"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX19PkIlKbjaO3gnP3WDFktXvEjhZLoNPoec="; posting-host="f3e663e33009b75e0973c148e80f63cf"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:qz2y0uTX38Dovq6qAUB3wHDahKo= sha256:8cv0u89qHQig9rov+3IhJH5gD964UU7WrcA/bMn7I9I=
	sha1:dG2HcpjImgL/1vSssG6Nnzqt3bs= sha256:en3D4CAIkRwAUm2N+fyVyz50y/vaouCdcvw3onufFWQ=
In-Reply-To: <11aunpn$8c6$1@reader2.panix.com>
Content-Language: en-US