]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: properly model rwmutex in lock ranking
authorMichael Pratt <mpratt@google.com>
Wed, 13 Dec 2023 20:07:28 +0000 (15:07 -0500)
committerMichael Pratt <mpratt@google.com>
Fri, 15 Dec 2023 22:00:45 +0000 (22:00 +0000)
commit9b4b3e5acca2dabe107fa2c3ed963097d78a4562
treebacab00af0ffbfd2c135e89229f43d3dbbbf3e09
parent793097161b3a263b2b0912265cf99d4d9c6218fa
runtime: properly model rwmutex in lock ranking

Currently, lock ranking doesn't really try to model rwmutex. It records
the internal locks rLock and wLock, but in a subpar fashion:

1. wLock is held from lock to unlock, so it works OK, but it conflates
   write locks of all rwmutexes as rwmutexW, rather than allowing
   different rwmutexes to have different rankings.
2. rLock is an internal implementation detail that is only taken when
   there is contention in rlock. As as result, the reader lock path is
   almost never checked.

Add proper modeling. rwmutexR and rwmutexW remain as the ranks of the
internal locks, which have their own ordering. The new init method is
passed the ranks of the higher level lock that this represents, just
like lockInit for mutex.

execW ordered before MALLOC captures the case from #64722. i.e., there
can be allocation between BeforeFork and AfterFork.

For #64722.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-staticlockranking
Change-Id: I23335b28faa42fb04f1bc9da02fdf54d1616cd28
Reviewed-on: https://go-review.googlesource.com/c/go/+/549536
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/runtime/export_test.go
src/runtime/lockrank.go
src/runtime/mklockrank.go
src/runtime/proc.go
src/runtime/rwmutex.go
src/runtime/rwmutex_test.go