Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tools/memory-model: Add atomic_andnot() with its variants

Pull-855[1] added the support of atomic_andnot() to the herd tool. Use
this to add the implementation in the LKMM. All of the ordering variants
are also added.

Here is a small litmus-test that uses this operation:

C andnot

{
atomic_t u = ATOMIC_INIT(7);
}

P0(atomic_t *u)
{

r0 = atomic_fetch_andnot(3, u);
r1 = READ_ONCE(*u);
}

exists (0:r0=7 /\ 0:r1=4)

Test andnot Allowed
States 1
0:r0=7; 0:r1=4;
Ok
Witnesses
Positive: 1 Negative: 0
Condition exists (0:r0=7 /\ 0:r1=4)
Observation andnot Always 1 0
Time andnot 0.00
Hash=78f011a0b5a0c65fa1cf106fcd62c845

[1] https://github.com/herd/herdtools7/pull/855

Signed-off-by: Puranjay Mohan <puranjay@kernel.org>
Acked-by: Andrea Parri <parri.andrea@gmail.com>
Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Will Deacon <will@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Jade Alglave <j.alglave@ucl.ac.uk>
Cc: Luc Maranget <luc.maranget@inria.fr>
Cc: Akira Yokosawa <akiyks@gmail.com>
Cc: Daniel Lustig <dlustig@nvidia.com>
Cc: Joel Fernandes <joel@joelfernandes.org>
Cc: <linux-arch@vger.kernel.org>

authored by

Puranjay Mohan and committed by
Paul E. McKenney
e176ebff 2ada0add

+6
+6
tools/memory-model/linux-kernel.def
··· 70 70 atomic_xor(V,X) { __atomic_op(X,^,V); } 71 71 atomic_inc(X) { __atomic_op(X,+,1); } 72 72 atomic_dec(X) { __atomic_op(X,-,1); } 73 + atomic_andnot(V,X) { __atomic_op(X,&~,V); } 73 74 74 75 atomic_add_return(V,X) __atomic_op_return{mb}(X,+,V) 75 76 atomic_add_return_relaxed(V,X) __atomic_op_return{once}(X,+,V) ··· 139 138 atomic_add_negative_relaxed(V,X) __atomic_op_return{once}(X,+,V) < 0 140 139 atomic_add_negative_acquire(V,X) __atomic_op_return{acquire}(X,+,V) < 0 141 140 atomic_add_negative_release(V,X) __atomic_op_return{release}(X,+,V) < 0 141 + 142 + atomic_fetch_andnot(V,X) __atomic_fetch_op{mb}(X,&~,V) 143 + atomic_fetch_andnot_acquire(V,X) __atomic_fetch_op{acquire}(X,&~,V) 144 + atomic_fetch_andnot_release(V,X) __atomic_fetch_op{release}(X,&~,V) 145 + atomic_fetch_andnot_relaxed(V,X) __atomic_fetch_op{once}(X,&~,V)