diff options
author | Michael Pratt <mpratt@google.com> | 2021-03-09 16:13:23 -0500 |
---|---|---|
committer | Michael Pratt <mpratt@google.com> | 2021-03-10 19:07:29 +0000 |
commit | c41bf9ee81e26d0fc0aca858a3d96d96be29ccba (patch) | |
tree | d3abc5b6ab1296f962c9aca089c750b3d31c7d2a /src/runtime/lockrank_on.go | |
parent | 5ce51ea74177513b473e2da05d0e4e9b7affb3c4 (diff) | |
download | go-c41bf9ee81e26d0fc0aca858a3d96d96be29ccba.tar.gz go-c41bf9ee81e26d0fc0aca858a3d96d96be29ccba.zip |
runtime: check partial lock ranking order
To ease readability we typically keep the partial order lists sorted by
rank. This isn't required for correctness, it just makes it (slightly)
easier to read the lists.
Currently we must notice out-of-order entries during code review, which
is an error-prone process.
Add a test to enforce ordering, and fix the errors that have crept in.
Most of the existing errors were misordered lockRankHchan or
lockRankPollDesc.
While we're here, I've moved the correctness check that the partial
ordering satisfies the total ordering from init to a test case. This
will allow us to catch these errors without even running
staticlockranking.
Change-Id: I9c11abe49ea26c556439822bb6a3183129600c3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/300171
Trust: Michael Pratt <mpratt@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Diffstat (limited to 'src/runtime/lockrank_on.go')
-rw-r--r-- | src/runtime/lockrank_on.go | 13 |
1 files changed, 0 insertions, 13 deletions
diff --git a/src/runtime/lockrank_on.go b/src/runtime/lockrank_on.go index 3958d9eeaa..fc8d2dc8d1 100644 --- a/src/runtime/lockrank_on.go +++ b/src/runtime/lockrank_on.go @@ -25,19 +25,6 @@ type lockRankStruct struct { pad int } -// init checks that the partial order in lockPartialOrder fits within the total -// order determined by the order of the lockRank constants. -func init() { - for rank, list := range lockPartialOrder { - for _, entry := range list { - if entry > lockRank(rank) { - println("lockPartial order row", lockRank(rank).String(), "entry", entry.String()) - throw("lockPartialOrder table is inconsistent with total lock ranking order") - } - } - } -} - func lockInit(l *mutex, rank lockRank) { l.rank = rank } |