]> Cypherpunks.ru repositories - gostls13.git/commit
runtime: clean up extra M API
authorMichael Pratt <mpratt@google.com>
Fri, 5 May 2023 20:35:10 +0000 (16:35 -0400)
committerGopher Robot <gobot@golang.org>
Mon, 8 May 2023 16:39:39 +0000 (16:39 +0000)
commit77b1f23af70eb6e02b4d2f5ad18e462b86156971
tree6314e8de90a73a073b95beb7a943a2660a748963
parent5cad8d41ca09b4c0f68a3f1fd81ada13d6855ff1
runtime: clean up extra M API

There are quite a few locations that get/put Ms from the extra M list,
but the API is pretty clumsy to use. Add an easier to use getExtraM /
putExtraM API.

There are only two minor semantic changes:

1. dropm no longer calls setg(nil) inside the lockextra critical
   section. It is important that this thread no longer references the G
   (and in turn M) once it is published to the extra M list and another
   thread could acquire it. But there is no reason that needs to happen
   only after lockextra.

2. extraMLength (renamed from extraMCount) is no longer protected by
   lockextra and is instead simply an atomic (though writes are still in
   the critical section). The previous readers all dropped lockextra
   before using the value they read anyway.

For #60004.

Change-Id: Ifca4d6c84d605423855d89f49af400ca07de56f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/492742
Run-TryBot: Michael Pratt <mpratt@google.com>
Commit-Queue: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
src/runtime/proc.go
src/runtime/signal_unix.go