From c41bf9ee81e26d0fc0aca858a3d96d96be29ccba Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Tue, 9 Mar 2021 16:13:23 -0500 Subject: 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 Trust: Dan Scales Run-TryBot: Michael Pratt TryBot-Result: Go Bot Reviewed-by: Dan Scales --- src/runtime/export_test.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/runtime/export_test.go') diff --git a/src/runtime/export_test.go b/src/runtime/export_test.go index a48bb2636f..5a87024b8a 100644 --- a/src/runtime/export_test.go +++ b/src/runtime/export_test.go @@ -46,6 +46,14 @@ var NetpollGenericInit = netpollGenericInit var Memmove = memmove var MemclrNoHeapPointers = memclrNoHeapPointers +var LockPartialOrder = lockPartialOrder + +type LockRank lockRank + +func (l LockRank) String() string { + return lockRank(l).String() +} + const PreemptMSupported = preemptMSupported type LFNode struct { -- cgit v1.3-5-g9baa