🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.arch
Article #266

Re: Performance of xchg reg,reg

#266
From: Chris M. Thomasson
Date: Tue, 20 Oct 2026 23:44
35 lines
3262 bytes
On 10/20/2026 7:09 AM, Scott Lurndal wrote:
> cross@spitfire.i.gajendra.net (Dan Cross) writes:
>> In article <jwv8q3uqrxf.fsf-monnier+comp.arch@gnu.org>,
>> Stefan Monnier  <monnier@iro.umontreal.ca> wrote:
>>> Anton Ertl [2026-10-18 16:57:26] wrote:
>>>> And actually all the stuff about XCHG with memory operands does not
>>>> contradict this sentence.  It could be understood as meaning that
>>>> while all the other aspects of locking don't apply to "XCHG reg, reg",
>>>> the assertion of the LOCK# signal still has to occur, and that's why
>>>> Intel processors implement a slow XCHG reg, reg.
>>>
>>> How could code witness the difference?
>>>
>>> I believe AMD can claim that its behavior is consistent with the
>>> behavior you'd get when asserting the LOCK# signal.
>>
>> The effects of a bus lock include disallowing memory operations
>> (except for instruction fetches or page table accesses) passing
>> a locked operation.  If `XCHG reg,reg` where indeed treated as
>> though it asserted `LOCK#` for the duration of its execution, it
>> could be (ab)used to force that behavior:  From sec 11.1.2.2 of
>> SDM Volume 3a (Sept 2026 version):
>>
> 
> It's worth noting that AMD processors (in the 2008 timeframe) would
> assert the LOCK# signal if a highly contended cache line could not
> be acquired in exclusive mode within a certain window of time,
> even if the access was completely encapsulated in said cache line.
> 
> I suspect that is still the case.

I almost have to agree. I think it was there for some sort of anti 
livelock...? Try bashing the shit out of a LOCK CMPXCHG with another 
thread just writing to the address trying to make the CAS fail, over and 
over again... It might force some internal logic to assert a real bus lock.
Technical Details
Message-ID: <11b8ucb$3fjht$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> <20261018184318.00000bee@yahoo.com> <2026Oct18.185726@mips.complang.tuwien.ac.at> <jwv8q3uqrxf.fsf-monnier+comp.arch@gnu.org> <11b6i0g$f44$1@reader2.panix.com> <kCKBS.68257$ACx3.16699@fx15.iad>

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: Tue, 20 Oct 2026 16:44:11 -0700
Organization: A noiseless patient Spider
Lines: 35
Message-ID: <11b8ucb$3fjht$1@dont-email.me>
References: <2026Oct13.104347@mips.complang.tuwien.ac.at>
 <20261018184318.00000bee@yahoo.com>
 <2026Oct18.185726@mips.complang.tuwien.ac.at>
 <jwv8q3uqrxf.fsf-monnier+comp.arch@gnu.org> <11b6i0g$f44$1@reader2.panix.com>
 <kCKBS.68257$ACx3.16699@fx15.iad>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 20 Oct 2026 23:44:12 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="3657277"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18v2BH/cD0eBOSNmTJLDn+aViNRKuwk3nA="; posting-host="ac8b421d91295724de1c891325ec3b23"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:yWtnM9O1ac9fmZoBPsf0uebtAmc= sha256:Mwydh5YdtCVZsDuPglvUwPLIspNPXFagWWXQKfSFvug=
	sha1:RcUL1/mCtY8AMs9+uwCjned1j00= sha256:xGMWDvLQNULlgVJmjPvSAToJQ5nKHh2wqV+yZJz20mQ=
Content-Language: en-US
In-Reply-To: <kCKBS.68257$ACx3.16699@fx15.iad>