From: Mathieu Desnoyers via lttng-dev <lttng-dev@lists.lttng.org>
To: "Ondřej Surý" <ondrej@sury.org>
Cc: lttng-dev@lists.lttng.org, paulmck <paulmck@kernel.org>
Subject: Re: [lttng-dev] [PATCH 2/7] Use gcc __atomic builtis for <urcu/uatomic.h> implementation
Date: Mon, 20 Mar 2023 14:41:12 -0400 [thread overview]
Message-ID: <bc2fd0fc-f6e3-def9-1cff-e6d86a79f644@efficios.com> (raw)
In-Reply-To: <912a8dd5-0451-1d11-7ffa-dd1094658c44@efficios.com>
On 2023-03-20 14:38, Mathieu Desnoyers via lttng-dev wrote:
> On 2023-03-20 14:28, Ondřej Surý wrote:
>>
>>> On 20. 3. 2023, at 19:03, Mathieu Desnoyers
>>> <mathieu.desnoyers@efficios.com> wrote:
>>>
>>> In doc/uatomic-api.md, we document:
>>>
>>> "```c
>>> type uatomic_cmpxchg(type *addr, type old, type new);
>>> ```
>>>
>>> An atomic read-modify-write operation that performs this
>>> sequence of operations atomically: check if `addr` contains `old`.
>>> If true, then replace the content of `addr` by `new`. Return the
>>> value previously contained by `addr`. This function implies a full
>>> memory barrier before and after the atomic operation."
>>>
>>> This would map to a "__ATOMIC_ACQ_REL" semantic on cmpxchg failure
>>> rather than __ATOMIC_CONSUME".
>>
>>
>> From: https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
>>
>>> If desired is written into *ptr then true is returned and memory is
>>> affected according to the memory order specified by success_memorder.
>>> There are no restrictions on what memory order can be used here.
>>>
>>> Otherwise, false is returned and memory is affected according to
>>> failure_memorder. This memory order cannot be __ATOMIC_RELEASE nor
>>> __ATOMIC_ACQ_REL. It also cannot be a stronger order than that
>>> specified by success_memorder.
>>
>> I think it makes sense that the failure_memorder has the same memorder
>> as uatomic_read(), but it definitelly cannot be __ATOMIC_ACQ_REL -
>> it's same as with __atomic_load_n, only following are permitted:
>>
>>> The valid memory order variants are __ATOMIC_RELAXED,
>>> __ATOMIC_SEQ_CST, __ATOMIC_ACQUIRE, and __ATOMIC_CONSUME.
>
> Based on my other reply, we want "SEQ_CST" rather than ACQ_REL everywhere.
And it _would_ make sense to use the same memorder on cmpxchg failure as
uatomic_read if we were exposing a new API, but we are modifying an
already exposed documented API, so I would stick to SEQ_CST for both
cmpxchg success/failure.
If we want to expose a new cmpxchg_relaxed_failure with a relaxed
memorder on failure that would be fine, but we cannot change the
semantic that is already documented.
Thanks,
Mathieu
>
> Thanks,
>
> Mathieu
>
>>
>> Ondrej
>> --
>> Ondřej Surý (He/Him)
>> ondrej@sury.org
>>
>
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
_______________________________________________
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
next prev parent reply other threads:[~2023-03-20 18:41 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-17 21:37 [lttng-dev] [PATCH 0/7] Replace the custom code with gcc/clang __atomic builtins Ondřej Surý via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 1/7] Require __atomic builtins to build Ondřej Surý via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 2/7] Use gcc __atomic builtis for <urcu/uatomic.h> implementation Ondřej Surý via lttng-dev
2023-03-20 18:03 ` Mathieu Desnoyers via lttng-dev
2023-03-20 18:13 ` Mathieu Desnoyers via lttng-dev
2023-03-20 18:28 ` Ondřej Surý via lttng-dev
2023-03-20 18:38 ` Mathieu Desnoyers via lttng-dev
2023-03-20 18:41 ` Mathieu Desnoyers via lttng-dev [this message]
2023-03-20 19:38 ` Duncan Sands via lttng-dev
2023-03-21 20:26 ` Mathieu Desnoyers via lttng-dev
2023-03-22 8:24 ` Duncan Sands via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 3/7] Use __atomic_thread_fence() for cmm_barrier() Ondřej Surý via lttng-dev
2023-03-20 18:06 ` Mathieu Desnoyers via lttng-dev
2023-03-20 18:14 ` Mathieu Desnoyers via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 4/7] Replace the internal pointer manipulation with __atomic builtins Ondřej Surý via lttng-dev
2023-03-20 18:25 ` Mathieu Desnoyers via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 5/7] Use __atomic builtins to implement CMM_{LOAD, STORE}_SHARED Ondřej Surý via lttng-dev
2023-03-20 18:28 ` Mathieu Desnoyers via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 6/7] Fix: uatomic_or() need retyping to uintptr_t in rculfhash.c Ondřej Surý via lttng-dev
2023-03-20 18:31 ` Mathieu Desnoyers via lttng-dev
2023-03-21 10:15 ` Ondřej Surý via lttng-dev
2023-03-21 14:44 ` Mathieu Desnoyers via lttng-dev
2023-03-21 14:45 ` Mathieu Desnoyers via lttng-dev
2023-03-17 21:37 ` [lttng-dev] [PATCH 7/7] Experiment: Add explicit memory barrier in free_completion() Ondřej Surý via lttng-dev
2023-03-20 18:37 ` Mathieu Desnoyers via lttng-dev
2023-03-21 10:21 ` Ondřej Surý via lttng-dev
2023-03-21 14:46 ` Mathieu Desnoyers via lttng-dev
2023-03-21 14:48 ` Ondřej Surý via lttng-dev
2023-03-21 14:49 ` Mathieu Desnoyers via lttng-dev
2023-03-21 14:59 ` [lttng-dev] TSAN and the tests Ondřej Surý via lttng-dev
2023-03-21 13:30 [lttng-dev] (no subject) Ondřej Surý via lttng-dev
2023-03-21 13:30 ` [lttng-dev] [PATCH 2/7] Use gcc __atomic builtis for <urcu/uatomic.h> implementation Ondřej Surý via lttng-dev
2023-03-21 20:03 ` Mathieu Desnoyers via lttng-dev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bc2fd0fc-f6e3-def9-1cff-e6d86a79f644@efficios.com \
--to=lttng-dev@lists.lttng.org \
--cc=mathieu.desnoyers@efficios.com \
--cc=ondrej@sury.org \
--cc=paulmck@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).