diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2018-05-14 19:33:50 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2018-05-15 02:11:17 -0400 |
commit | 8559183ccaec97454b2515ac426f113967256cf9 (patch) | |
tree | 6aee2f09189b0b9441ecfb3c399078158424fb71 | |
parent | 1bd3742043fa44dd0ec25770abdcdfe1f6e8681e (diff) |
tools/memory-model: Remove duplicated code from lock.cat
This patch simplifies the implementation of spin_is_locked in the
LKMM. It capitalizes on the fact that a failed spin_trylock() and a
spin_is_locked() which returns True have exactly the same semantics
(those of READ_ONCE) and ordering properties (none). Therefore the
two kinds of events can be combined and handled by the same code,
instead of treated separately as they are currently.
Tested-by: Andrea Parri <andrea.parri@amarulasolutions.com>
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Akira Yokosawa <akiyks@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Boqun Feng <boqun.feng@gmail.com>
Cc: David Howells <dhowells@redhat.com>
Cc: Jade Alglave <j.alglave@ucl.ac.uk>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Luc Maranget <luc.maranget@inria.fr>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: linux-arch@vger.kernel.org
Cc: parri.andrea@gmail.com
Link: http://lkml.kernel.org/r/1526340837-12222-12-git-send-email-paulmck@linux.vnet.ibm.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | tools/memory-model/lock.cat | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/tools/memory-model/lock.cat b/tools/memory-model/lock.cat index 3b1439edc818..1f6d67e79065 100644 --- a/tools/memory-model/lock.cat +++ b/tools/memory-model/lock.cat | |||
@@ -41,11 +41,15 @@ flag ~empty [FW] ; loc ; [ALL-LOCKS] as lock-final | |||
41 | *) | 41 | *) |
42 | let RL = try RL with emptyset (* defined herd7 >= 7.49 *) | 42 | let RL = try RL with emptyset (* defined herd7 >= 7.49 *) |
43 | let RU = try RU with emptyset (* defined herd7 >= 7.49 *) | 43 | let RU = try RU with emptyset (* defined herd7 >= 7.49 *) |
44 | |||
45 | (* Treat RL as a kind of LF: a read with no ordering properties *) | ||
46 | let LF = LF | RL | ||
47 | |||
44 | (* | 48 | (* |
45 | * Put lock operations in their appropriate classes, but leave UL out of W | 49 | * Put lock operations in their appropriate classes, but leave UL out of W |
46 | * until after the co relation has been generated. | 50 | * until after the co relation has been generated. |
47 | *) | 51 | *) |
48 | let R = R | LKR | LF | RL | RU | 52 | let R = R | LKR | LF | RU |
49 | let W = W | LKW | 53 | let W = W | LKW |
50 | 54 | ||
51 | let Release = Release | UL | 55 | let Release = Release | UL |
@@ -80,28 +84,8 @@ let all-possible-rfe-lf = | |||
80 | 84 | ||
81 | (* Generate all rf relations for LF events *) | 85 | (* Generate all rf relations for LF events *) |
82 | with rfe-lf from cross(all-possible-rfe-lf) | 86 | with rfe-lf from cross(all-possible-rfe-lf) |
83 | |||
84 | let rf-lf = rfe-lf | rfi-lf | 87 | let rf-lf = rfe-lf | rfi-lf |
85 | 88 | ||
86 | (* rf for RL events, ie islocked returning true, similar to LF above *) | ||
87 | |||
88 | (* islocked returning true inside a critical section | ||
89 | * must read from the opening lock | ||
90 | *) | ||
91 | let rfi-rl = ([LKW] ; po-loc ; [RL]) \ ([LKW] ; po-loc ; [UL] ; po-loc) | ||
92 | |||
93 | (* islocked returning true outside critical sections can match any | ||
94 | * external lock. | ||
95 | *) | ||
96 | let all-possible-rfe-rl = | ||
97 | let possible-rfe-lf r = | ||
98 | let pair-to-relation p = p ++ 0 | ||
99 | in map pair-to-relation ((LKW * {r}) & loc & ext) | ||
100 | in map possible-rfe-lf (RL \ range(rfi-rl)) | ||
101 | |||
102 | with rfe-rl from cross(all-possible-rfe-rl) | ||
103 | let rf-rl = rfe-rl | rfi-rl | ||
104 | |||
105 | (* Read from unlock, ie islocked returning false, slightly different *) | 89 | (* Read from unlock, ie islocked returning false, slightly different *) |
106 | 90 | ||
107 | (* islocked returning false can read from the last po-previous unlock *) | 91 | (* islocked returning false can read from the last po-previous unlock *) |
@@ -118,7 +102,7 @@ with rfe-ru from cross(all-possible-rfe-ru) | |||
118 | let rf-ru = rfe-ru | rfi-ru | 102 | let rf-ru = rfe-ru | rfi-ru |
119 | 103 | ||
120 | (* Final rf relation *) | 104 | (* Final rf relation *) |
121 | let rf = rf | rf-lf | rf-rl | rf-ru | 105 | let rf = rf | rf-lf | rf-ru |
122 | 106 | ||
123 | (* Generate all co relations, including LKW events but not UL *) | 107 | (* Generate all co relations, including LKW events but not UL *) |
124 | let co0 = co0 | ([IW] ; loc ; [LKW]) | | 108 | let co0 = co0 | ([IW] ; loc ; [LKW]) | |