* [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
@ 2024-05-08 14:34 Puranjay Mohan
2024-05-08 15:28 ` Andrea Parri
2024-05-08 19:49 ` Boqun Feng
0 siblings, 2 replies; 6+ messages in thread
From: Puranjay Mohan @ 2024-05-08 14:34 UTC (permalink / raw)
To: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra, Boqun Feng,
Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
linux-kernel, linux-arch
Cc: puranjay12
Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
atomics operations.
Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
all their ordering variants.
atomic_add_negative() is already available so add its acquire, release,
and relaxed ordering variants.
[1] https://github.com/herd/herdtools7/pull/849
Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
---
tools/memory-model/linux-kernel.def | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/tools/memory-model/linux-kernel.def b/tools/memory-model/linux-kernel.def
index 88a39601f525..d1f11930ec51 100644
--- a/tools/memory-model/linux-kernel.def
+++ b/tools/memory-model/linux-kernel.def
@@ -65,6 +65,9 @@ atomic_set_release(X,V) { smp_store_release(X,V); }
atomic_add(V,X) { __atomic_op(X,+,V); }
atomic_sub(V,X) { __atomic_op(X,-,V); }
+atomic_and(V,X) { __atomic_op(X,&,V); }
+atomic_or(V,X) { __atomic_op(X,|,V); }
+atomic_xor(V,X) { __atomic_op(X,^,V); }
atomic_inc(X) { __atomic_op(X,+,1); }
atomic_dec(X) { __atomic_op(X,-,1); }
@@ -77,6 +80,21 @@ atomic_fetch_add_relaxed(V,X) __atomic_fetch_op{once}(X,+,V)
atomic_fetch_add_acquire(V,X) __atomic_fetch_op{acquire}(X,+,V)
atomic_fetch_add_release(V,X) __atomic_fetch_op{release}(X,+,V)
+atomic_fetch_and(V,X) __atomic_fetch_op{mb}(X,&,V)
+atomic_fetch_and_relaxed(V,X) __atomic_fetch_op{once}(X,&,V)
+atomic_fetch_and_acquire(V,X) __atomic_fetch_op{acquire}(X,&,V)
+atomic_fetch_and_release(V,X) __atomic_fetch_op{release}(X,&,V)
+
+atomic_fetch_or(V,X) __atomic_fetch_op{mb}(X,|,V)
+atomic_fetch_or_relaxed(V,X) __atomic_fetch_op{once}(X,|,V)
+atomic_fetch_or_acquire(V,X) __atomic_fetch_op{acquire}(X,|,V)
+atomic_fetch_or_release(V,X) __atomic_fetch_op{release}(X,|,V)
+
+atomic_fetch_xor(V,X) __atomic_fetch_op{mb}(X,^,V)
+atomic_fetch_xor_relaxed(V,X) __atomic_fetch_op{once}(X,^,V)
+atomic_fetch_xor_acquire(V,X) __atomic_fetch_op{acquire}(X,^,V)
+atomic_fetch_xor_release(V,X) __atomic_fetch_op{release}(X,^,V)
+
atomic_inc_return(X) __atomic_op_return{mb}(X,+,1)
atomic_inc_return_relaxed(X) __atomic_op_return{once}(X,+,1)
atomic_inc_return_acquire(X) __atomic_op_return{acquire}(X,+,1)
@@ -117,3 +135,6 @@ atomic_sub_and_test(V,X) __atomic_op_return{mb}(X,-,V) == 0
atomic_dec_and_test(X) __atomic_op_return{mb}(X,-,1) == 0
atomic_inc_and_test(X) __atomic_op_return{mb}(X,+,1) == 0
atomic_add_negative(V,X) __atomic_op_return{mb}(X,+,V) < 0
+atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0
+atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0
+atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0
--
2.40.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
2024-05-08 14:34 [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Puranjay Mohan
@ 2024-05-08 15:28 ` Andrea Parri
2024-05-08 17:34 ` Paul E. McKenney
2024-05-08 19:49 ` Boqun Feng
1 sibling, 1 reply; 6+ messages in thread
From: Andrea Parri @ 2024-05-08 15:28 UTC (permalink / raw)
To: Puranjay Mohan
Cc: Alan Stern, Will Deacon, Peter Zijlstra, Boqun Feng,
Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
linux-kernel, linux-arch, puranjay12
On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote:
> Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
> atomics operations.
>
> Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
> all their ordering variants.
>
> atomic_add_negative() is already available so add its acquire, release,
> and relaxed ordering variants.
>
> [1] https://github.com/herd/herdtools7/pull/849
>
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Andrea Parri <parri.andrea@gmail.com>
Thanks,
Andrea
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
2024-05-08 15:28 ` Andrea Parri
@ 2024-05-08 17:34 ` Paul E. McKenney
0 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2024-05-08 17:34 UTC (permalink / raw)
To: Andrea Parri
Cc: Puranjay Mohan, Alan Stern, Will Deacon, Peter Zijlstra,
Boqun Feng, Nicholas Piggin, David Howells, Jade Alglave,
Luc Maranget, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
linux-kernel, linux-arch, puranjay12
On Wed, May 08, 2024 at 05:28:22PM +0200, Andrea Parri wrote:
> On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote:
> > Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
> > atomics operations.
> >
> > Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
> > all their ordering variants.
> >
> > atomic_add_negative() is already available so add its acquire, release,
> > and relaxed ordering variants.
> >
> > [1] https://github.com/herd/herdtools7/pull/849
> >
> > Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
>
> Acked-by: Andrea Parri <parri.andrea@gmail.com>
Queued for review and testing, and thank you both!
Thanx, Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
2024-05-08 14:34 [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Puranjay Mohan
2024-05-08 15:28 ` Andrea Parri
@ 2024-05-08 19:49 ` Boqun Feng
2024-05-08 21:59 ` Akira Yokosawa
1 sibling, 1 reply; 6+ messages in thread
From: Boqun Feng @ 2024-05-08 19:49 UTC (permalink / raw)
To: Puranjay Mohan
Cc: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra,
Nicholas Piggin, David Howells, Jade Alglave, Luc Maranget,
Paul E. McKenney, Akira Yokosawa, Daniel Lustig, Joel Fernandes,
linux-kernel, linux-arch, puranjay12
On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote:
> Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
> atomics operations.
>
> Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
> all their ordering variants.
>
> atomic_add_negative() is already available so add its acquire, release,
> and relaxed ordering variants.
>
> [1] https://github.com/herd/herdtools7/pull/849
A newer version of herd is required for this feature, right? So please
also do a change in tools/memory-model/README "REQUIREMENTS" session
when the new version released.
Needless to say, this patch looks good to me.
Reviewed-by: Boqun Feng <boqun.feng@gmail.com>
Regards,
Boqun
>
> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> ---
> tools/memory-model/linux-kernel.def | 21 +++++++++++++++++++++
> 1 file changed, 21 insertions(+)
>
> diff --git a/tools/memory-model/linux-kernel.def b/tools/memory-model/linux-kernel.def
> index 88a39601f525..d1f11930ec51 100644
> --- a/tools/memory-model/linux-kernel.def
> +++ b/tools/memory-model/linux-kernel.def
> @@ -65,6 +65,9 @@ atomic_set_release(X,V) { smp_store_release(X,V); }
>
> atomic_add(V,X) { __atomic_op(X,+,V); }
> atomic_sub(V,X) { __atomic_op(X,-,V); }
> +atomic_and(V,X) { __atomic_op(X,&,V); }
> +atomic_or(V,X) { __atomic_op(X,|,V); }
> +atomic_xor(V,X) { __atomic_op(X,^,V); }
> atomic_inc(X) { __atomic_op(X,+,1); }
> atomic_dec(X) { __atomic_op(X,-,1); }
>
> @@ -77,6 +80,21 @@ atomic_fetch_add_relaxed(V,X) __atomic_fetch_op{once}(X,+,V)
> atomic_fetch_add_acquire(V,X) __atomic_fetch_op{acquire}(X,+,V)
> atomic_fetch_add_release(V,X) __atomic_fetch_op{release}(X,+,V)
>
> +atomic_fetch_and(V,X) __atomic_fetch_op{mb}(X,&,V)
> +atomic_fetch_and_relaxed(V,X) __atomic_fetch_op{once}(X,&,V)
> +atomic_fetch_and_acquire(V,X) __atomic_fetch_op{acquire}(X,&,V)
> +atomic_fetch_and_release(V,X) __atomic_fetch_op{release}(X,&,V)
> +
> +atomic_fetch_or(V,X) __atomic_fetch_op{mb}(X,|,V)
> +atomic_fetch_or_relaxed(V,X) __atomic_fetch_op{once}(X,|,V)
> +atomic_fetch_or_acquire(V,X) __atomic_fetch_op{acquire}(X,|,V)
> +atomic_fetch_or_release(V,X) __atomic_fetch_op{release}(X,|,V)
> +
> +atomic_fetch_xor(V,X) __atomic_fetch_op{mb}(X,^,V)
> +atomic_fetch_xor_relaxed(V,X) __atomic_fetch_op{once}(X,^,V)
> +atomic_fetch_xor_acquire(V,X) __atomic_fetch_op{acquire}(X,^,V)
> +atomic_fetch_xor_release(V,X) __atomic_fetch_op{release}(X,^,V)
> +
> atomic_inc_return(X) __atomic_op_return{mb}(X,+,1)
> atomic_inc_return_relaxed(X) __atomic_op_return{once}(X,+,1)
> atomic_inc_return_acquire(X) __atomic_op_return{acquire}(X,+,1)
> @@ -117,3 +135,6 @@ atomic_sub_and_test(V,X) __atomic_op_return{mb}(X,-,V) == 0
> atomic_dec_and_test(X) __atomic_op_return{mb}(X,-,1) == 0
> atomic_inc_and_test(X) __atomic_op_return{mb}(X,+,1) == 0
> atomic_add_negative(V,X) __atomic_op_return{mb}(X,+,V) < 0
> +atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0
> +atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0
> +atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0
> --
> 2.40.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
2024-05-08 19:49 ` Boqun Feng
@ 2024-05-08 21:59 ` Akira Yokosawa
2024-05-08 23:46 ` Paul E. McKenney
0 siblings, 1 reply; 6+ messages in thread
From: Akira Yokosawa @ 2024-05-08 21:59 UTC (permalink / raw)
To: Boqun Feng, Puranjay Mohan, Luc Maranget
Cc: Alan Stern, Andrea Parri, Will Deacon, Peter Zijlstra,
Nicholas Piggin, David Howells, Jade Alglave, Paul E. McKenney,
Daniel Lustig, Joel Fernandes, linux-kernel, linux-arch,
puranjay12, Akira Yokosawa
On Wed, 8 May 2024 12:49:57 -0700, Boqun Feng wrote:
> On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote:
>> Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
>> atomics operations.
>>
>> Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
>> all their ordering variants.
>>
>> atomic_add_negative() is already available so add its acquire, release,
>> and relaxed ordering variants.
>>
>> [1] https://github.com/herd/herdtools7/pull/849
>
> A newer version of herd is required for this feature, right?
Yes, this requires building herd7 from latest source.
herdtools7 7.57 (released recently) happened before pull 849.
Luc, what is your plan on a next release (7.57.1?) ?
> So please
> also do a change in tools/memory-model/README "REQUIREMENTS" session
> when the new version released.
Puranjay, it would be great if you add some litmus tests which use
additional atomic primitives under tools/memory-model/litmus-tests/
as well.
Thanks, Akira
> Boqun
>
>>
>> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
>> ---
>> tools/memory-model/linux-kernel.def | 21 +++++++++++++++++++++
>> 1 file changed, 21 insertions(+)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative
2024-05-08 21:59 ` Akira Yokosawa
@ 2024-05-08 23:46 ` Paul E. McKenney
0 siblings, 0 replies; 6+ messages in thread
From: Paul E. McKenney @ 2024-05-08 23:46 UTC (permalink / raw)
To: Akira Yokosawa
Cc: Boqun Feng, Puranjay Mohan, Luc Maranget, Alan Stern,
Andrea Parri, Will Deacon, Peter Zijlstra, Nicholas Piggin,
David Howells, Jade Alglave, Daniel Lustig, Joel Fernandes,
linux-kernel, linux-arch, puranjay12
On Thu, May 09, 2024 at 06:59:17AM +0900, Akira Yokosawa wrote:
> On Wed, 8 May 2024 12:49:57 -0700, Boqun Feng wrote:
> > On Wed, May 08, 2024 at 02:34:00PM +0000, Puranjay Mohan wrote:
> >> Pull-849[1] added the support of '&', '|', and '^' to the herd7 tool's
> >> atomics operations.
> >>
> >> Use these in linux-kernel.def to implement atomic_and()/or()/xor() with
> >> all their ordering variants.
> >>
> >> atomic_add_negative() is already available so add its acquire, release,
> >> and relaxed ordering variants.
> >>
> >> [1] https://github.com/herd/herdtools7/pull/849
> >
> > A newer version of herd is required for this feature, right?
>
> Yes, this requires building herd7 from latest source.
>
> herdtools7 7.57 (released recently) happened before pull 849.
>
> Luc, what is your plan on a next release (7.57.1?) ?
>
> > So please
> > also do a change in tools/memory-model/README "REQUIREMENTS" session
> > when the new version released.
>
> Puranjay, it would be great if you add some litmus tests which use
> additional atomic primitives under tools/memory-model/litmus-tests/
> as well.
Thank you for checking, Akira! I need to hold off sending this upstream
until there is a herdtools7 release that supports it. So not the merge
window that is likely to open this weekend. ;-)
Thanx, Paul
> Thanks, Akira
>
> > Boqun
> >
> >>
> >> Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
> >> ---
> >> tools/memory-model/linux-kernel.def | 21 +++++++++++++++++++++
> >> 1 file changed, 21 insertions(+)
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-05-08 23:46 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 14:34 [PATCH] tools/memory-model: Add atomic_and()/or()/xor() and add_negative Puranjay Mohan
2024-05-08 15:28 ` Andrea Parri
2024-05-08 17:34 ` Paul E. McKenney
2024-05-08 19:49 ` Boqun Feng
2024-05-08 21:59 ` Akira Yokosawa
2024-05-08 23:46 ` Paul E. McKenney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox