Deutsch   English   Français   Italiano  
<vkd46o$1fvln$5@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: "Chris M. Thomasson" <chris.m.thomasson.1@gmail.com>
Newsgroups: comp.arch
Subject: Re: Strange asm generated by GCC...
Date: Mon, 23 Dec 2024 17:53:28 -0800
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <vkd46o$1fvln$5@dont-email.me>
References: <vk2ek2$33ckv$3@dont-email.me> <vk4ahk$3i1bs$1@dont-email.me>
 <At6cnfsh1ZzpB_v6nZ2dnZfqn_adnZ2d@supernews.com>
 <vkamjt$11jv0$2@dont-email.me> <vkamr2$11jv0$3@dont-email.me>
 <h0ydnQ-XeaVIvfT6nZ2dnZfqnPednZ2d@supernews.com>
 <vkck71$1cp7c$1@dont-email.me> <vkd20o$1fk7q$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 24 Dec 2024 02:53:28 +0100 (CET)
Injection-Info: dont-email.me; posting-host="d7ce48cf38462b28073ed26d9c338b5a";
	logging-data="1572535"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18fxOxTkjeX7LwqYjL4vTglmvqUHbDxAP0="
User-Agent: Mozilla Thunderbird
Cancel-Lock: sha1:1kUzkzdgBgGWIkWZ66C8ngJVT1o=
In-Reply-To: <vkd20o$1fk7q$1@dont-email.me>
Content-Language: en-US
Bytes: 2288

On 12/23/2024 5:16 PM, jseigh wrote:
> On 12/23/24 16:20, Chris M. Thomasson wrote:
> 
>>
>> Wrt a traditional lock-free stack, I think the store can use relaxed 
>> for the success path of a CAS.
> 
> For pushing onto a stack, you want release.  For popping from a stack
> you want acquire.

Right. We want the release right before we atomically introduce the node 
into the stack. For the pop, we can load the head and do an acquire wrt 
the loop. load the next node in said loop, do the CAS. The success part 
of the CAS can be a relaxed, the failure would need an another acquire?


> 
> You are probably ok using relaxed loading the old value.  It's not
> real clear how aggressive the compiler is allowed to be with relaxed
> loads and stores.  To be super safe, you might want to add acquire
> to all your cas loops.
> 
> I would just stick with the compare_exchange w/ 1 memory order
> parameter.  The success/fail form is just confusing, the fail
> parameter doesn't do anything.
> 
>