🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c++
Article #49

Re: Consequential RCU

#49
From: Chris M. Thomasson
Date: Fri, 09 Oct 2026 00:15
56 lines
4832 bytes
On 10/4/2026 2:34 AM, David Brown wrote:
> On 03/10/2026 23:12, Chris M. Thomasson wrote:
>> On 10/3/2026 8:50 AM, boltar@caprica.universe wrote:
>>> On Sat, 3 Oct 2026 14:19:56 +0200
>>> David Brown <david.brown@hesbynett.no> gabbled:
>>>> On 02/10/2026 20:13, Chris M. Thomasson wrote:
>>>>> It should be something akin to, why do I feel the need to code this 
>>>>> is ASM when the C/C++11 should already do it for me. That type of 
>>>>> angle?
>>>>
>>>> Something along these lines should be fine.  There may be some 
>>>> underlying reason why this is implemented as a library call in gcc's 
>>>> C++ standard library, rather than a direct lock-free opcode.  I 
>>>> don't know the details of any of this - maybe there are flaws in 
>>>> some chips, maybe the single op-code actually takes longer than a 
>>>> lock- based implementation.  Maybe it's just that no one has got 
>>>> round to implementing it yet.
>>>
>>> I would guess the reason is consistent behaviour across different 
>>> architectures.
>>>
>>
>> Well, if the library call goes to LOCK CMPXCHG16B for what we need it 
>> for then that would be okay. We need to step into the library call to 
>> find out.
> 
>  From what I have looked at, including the bugzilla link Joseph posted, 
> there seem to be a number of complications involved.  A particular 
> sticking point is that you can't have lock-free C++ standard atomic 
> types without also having atomic load and store operations of the same 
> size.  And while the 16-byte CAS can be used for loads and stores, it 
> can't be used for 16-byte atomic loads on read-only memory.  This means 
> that on older 64-bit x86 processors, 16-byte atomic types cannot be 
> lock-free even if they support 16-byte CAS.
> 
> It seems that the libatomic implementation does, in some cases, use the 
> CMPXCHG16B instruction rather than a mutex.  The exact code run in the 
> library depends on the cpuid of the processor, as well as compiler 
> flags.  (The default "lowest common denominator" x86-64 instruction set 
> does not support CMPXCHG16B.)
> 
> So the C++ standard library atomics do not lead directly to the use of 
> the lock-free instruction.  But if you have the "-mxc16" compiler flag 
> (or use a -march flag for a cpu family that supports it), then you can 
> use the low-level builtin __sync_bool_compare_and_swap to generate it.
> 
> Better still, in gcc 17 (in development) you can use the "-m128bit- 
> atomic" flag to get full 16-byte atomics on processors for which the GCC 
> folks have assurances from Intel or AMD that the 128-bit SSE2 vector 
> loads and stores are atomic.  You can try this on godbolt.org.
> 
> 

Well, see, just because I need to use DWCAS (LOCK CMPXCHG16B) on x64, 
for certain algos does not mean I want full double adjacent word loads 
and stores. That is besides the point.
Technical Details
Message-ID: <11a9bml$b09r$2@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: <118f4vv$3plsv$1@dont-email.me> <118mrl9$2j5vk$1@dont-email.me> <118os9o$36ell$1@dont-email.me> <118pp3b$3hhhe$2@dont-email.me> <118r96b$3ubta$1@dont-email.me> <118rjhu$3h1al$1@dont-email.me> <118rmuv$4lbb$1@dont-email.me> <11967a6$3oc1h$1@raubtier-asyl.eternal-september.org> <1196c4f$3q9m3$1@dont-email.me> <1196g18$3rvnj$1@dont-email.me> <1196oje$3v5oj$1@dont-email.me> <1198dcn$feci$1@dont-email.me> <11996sr$ob49$1@dont-email.me> <119b3pl$1ahkb$1@dont-email.me> <119er16$2pe7v$1@dont-email.me> <119flvc$316ju$1@dont-email.me> <119os83$2bmlo$2@dont-email.me> <119qrtc$306a9$1@dont-email.me> <119r87l$34smh$1@dont-email.me> <119rr3b$3c208$1@dont-email.me> <119t6j5$3oplg$1@dont-email.me>

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.lang.c++
Subject: Re: Consequential RCU
Date: Thu, 8 Oct 2026 17:15:17 -0700
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <11a9bml$b09r$2@dont-email.me>
References: <118f4vv$3plsv$1@dont-email.me> <118mrl9$2j5vk$1@dont-email.me>
 <118os9o$36ell$1@dont-email.me> <118pp3b$3hhhe$2@dont-email.me>
 <118r96b$3ubta$1@dont-email.me> <118rjhu$3h1al$1@dont-email.me>
 <118rmuv$4lbb$1@dont-email.me>
 <11967a6$3oc1h$1@raubtier-asyl.eternal-september.org>
 <1196c4f$3q9m3$1@dont-email.me> <1196g18$3rvnj$1@dont-email.me>
 <1196oje$3v5oj$1@dont-email.me> <1198dcn$feci$1@dont-email.me>
 <11996sr$ob49$1@dont-email.me> <119b3pl$1ahkb$1@dont-email.me>
 <119er16$2pe7v$1@dont-email.me> <119flvc$316ju$1@dont-email.me>
 <119os83$2bmlo$2@dont-email.me> <119qrtc$306a9$1@dont-email.me>
 <119r87l$34smh$1@dont-email.me> <119rr3b$3c208$1@dont-email.me>
 <119t6j5$3oplg$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 09 Oct 2026 00:15:18 +0000 (UTC)
Injection-Info: dont-email.me;
	logging-data="360763"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18c3nOc1HtPTRhdUuhIK1vBvw/PsaTVL3c="; posting-host="61576c8cd7392d5224927fcaadf1a471"
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:ULXkyHNv3T4eAUfzervr6ZAvizE= sha256:zuLNorhUuUVhH0qSwMQPdl/wAe59TAIm27Ge0hRRwjs=
	sha1:boaZomP0rrMxGEOcMJdlnDgwAg4= sha256:tthePmxPg+LOsK+1Q28smWNe1sneSrOGuuEpOZD928w=
In-Reply-To: <119t6j5$3oplg$1@dont-email.me>
Content-Language: en-US