aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/proc.go
AgeCommit message (Collapse)Author
2021-08-12[dev.typeparams] all: merge master (46fd547) into dev.typeparamsMatthew Dempsky
Conflicts: - src/go/types/check_test.go CL 324730 on dev.typeparams changed the directory paths in TestCheck, TestExamples, and TestFixedbugs and renamed checkFiles to testFiles; whereas CL 337529 on master added a new test case just above them and that used checkFiles. Merge List: + 2021-08-12 46fd547d89 internal/goversion: update Version to 1.18 + 2021-08-12 5805efc78e doc/go1.17: remove draft notice + 2021-08-12 39634e7dae CONTRIBUTORS: update for the Go 1.17 release + 2021-08-12 095bb790e1 os/exec: re-enable LookPathTest/16 + 2021-08-11 dea23e9ca8 src/make.*: make --no-clean flag a no-op that prints a warning + 2021-08-11 d4c0ed26ac doc/go1.17: linker passes -I to extld as -Wl,--dynamic-linker + 2021-08-10 1f9c9d8530 doc: use "high address/low address" instead of "top/bottom" + 2021-08-09 f1dce319ff cmd/go: with -mod=vendor, don't panic if there are duplicate requirements + 2021-08-09 7aeaad5c86 runtime/cgo: when using msan explicitly unpoison cgoCallers + 2021-08-08 507cc341ec doc: add example for conversion from slice expressions to array ptr + 2021-08-07 891547e2d4 doc/go1.17: fix a typo introduced in CL 335135 + 2021-08-06 8eaf4d16bc make.bash: do not overwrite GO_LDSO if already set + 2021-08-06 63b968f4f8 doc/go1.17: clarify Modules changes + 2021-08-06 70546f6404 runtime: allow arm64 SEH to be called if illegal instruction + 2021-08-05 fd45e267c2 runtime: warn that KeepAlive is not an unsafe.Pointer workaround + 2021-08-04 6e738868a7 net/http: speed up and deflake TestCancelRequestWhenSharingConnection + 2021-08-02 8a7ee4c51e io/fs: don't use absolute path in DirEntry.Name doc + 2021-07-31 b8ca6e59ed all: gofmt + 2021-07-30 b7a85e0003 net/http/httputil: close incoming ReverseProxy request body + 2021-07-29 70fd4e47d7 runtime: avoid possible preemption when returning from Go to C + 2021-07-28 9eee0ed439 cmd/go: fix go.mod file name printed in error messages for replacements + 2021-07-28 b39e0f461c runtime: don't crash on nil pointers in checkptrAlignment + 2021-07-27 7cd10c1149 cmd/go: use .mod instead of .zip to determine if version has go.mod file + 2021-07-27 c8cf0f74e4 cmd/go: add missing flag in UsageLine + 2021-07-27 7ba8e796c9 testing: clarify T.Name returns a distinct name of the running test + 2021-07-27 33ff155970 go/types: preserve untyped constants on the RHS of a shift expression + 2021-07-26 840e583ff3 runtime: correct variable name in comment + 2021-07-26 bfbb288574 runtime: remove adjustTimers counter + 2021-07-26 9c81fd53b3 cmd/vet: add missing copyright header Change-Id: Ia80604d24c6f4205265683024e3100769cf32065
2021-07-26runtime: remove adjustTimers counterIan Lance Taylor
In CL 336432 we changed adjusttimers so that it no longer cleared timerModifiedEarliest if there were no timersModifiedEarlier timers. This caused some Google internal tests to time out, presumably due to the increased contention on timersLock. We can avoid that by simply not skipping the loop in adjusttimers, which lets us safely clear timerModifiedEarliest. And if we don't skip the loop, then there isn't much reason to keep the count of timerModifiedEarlier timers at all. So remove it. The effect will be that for programs that create some timerModifiedEarlier timers and then remove them all, the program will do an occasional additional loop over all the timers. And, programs that have some timerModifiedEarlier timers will always loop over all the timers, without the quicker exit when they have all been seen. But the loops should not occur all that often, due to timerModifiedEarliest. For #47329 Change-Id: I7b244c1244d97b169a3c7fbc8f8a8b115731ddee Reviewed-on: https://go-review.googlesource.com/c/go/+/337309 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com>
2021-06-30[dev.typeparams] all: merge master (4711bf3) into dev.typeparamsMatthew Dempsky
Conflicts: - src/cmd/compile/internal/walk/builtin.go On dev.typeparams, CL 330194 changed OCHECKNIL to not require manual SetTypecheck(1) anymore; while on master, CL 331070 got rid of the OCHECKNIL altogether by moving the check into the runtime support functions. - src/internal/buildcfg/exp.go On master, CL 331109 refactored the logic for parsing the GOEXPERIMENT string, so that it could be more easily reused by cmd/go; while on dev.typeparams, several CLs tweaked the regabi experiment defaults. Merge List: + 2021-06-30 4711bf30e5 doc/go1.17: linkify "language changes" in the runtime section + 2021-06-30 ed56ea73e8 path/filepath: deflake TestEvalSymlinksAboveRoot on darwin + 2021-06-30 c080d0323b cmd/dist: pass -Wno-unknown-warning-option in swig_callback_lto + 2021-06-30 7d0e9e6e74 image/gif: fix typo in the comment (io.ReadByte -> io.ByteReader) + 2021-06-30 0fa3265fe1 os: change example to avoid deprecated function + 2021-06-30 d19a53338f image: add Uniform.RGBA64At and Rectangle.RGBA64At + 2021-06-30 c45e800e0c crypto/x509: don't fail on optional auth key id fields + 2021-06-29 f9d50953b9 net: fix failure of TestCVE202133195 + 2021-06-29 e294b8a49e doc/go1.17: fix typo "MacOS" -> "macOS" + 2021-06-29 3463852b76 math/big: fix typo of comment (`BytesScanner` to `ByteScanner`) + 2021-06-29 fd4b587da3 cmd/compile: suppress details error for invalid variadic argument type + 2021-06-29 e2e05af6e1 cmd/internal/obj/arm64: fix an encoding error of CMPW instruction + 2021-06-28 4bb0847b08 cmd/compile,runtime: change unsafe.Slice((*T)(nil), 0) to return []T(nil) + 2021-06-28 1519271a93 spec: change unsafe.Slice((*T)(nil), 0) to return []T(nil) + 2021-06-28 5385e2386b runtime/internal/atomic: drop Cas64 pointer indirection in comments + 2021-06-28 956c81bfe6 cmd/go: add GOEXPERIMENT to `go env` output + 2021-06-28 a1d27269d6 cmd/go: prep for 'go env' refactoring + 2021-06-28 901510ed4e cmd/link/internal/ld: skip the windows ASLR test when CGO_ENABLED=0 + 2021-06-28 361159c055 cmd/cgo: fix 'see gmp.go' to 'see doc.go' + 2021-06-27 c95464f0ea internal/buildcfg: refactor GOEXPERIMENT parsing code somewhat + 2021-06-25 ed01ceaf48 runtime/race: use race build tag on syso_test.go + 2021-06-25 d1916e5e84 go/types: in TestCheck/issues.src, import regexp/syntax instead of cmd/compile/internal/syntax + 2021-06-25 5160896c69 go/types: in TestStdlib, import from source instead of export data + 2021-06-25 d01bc571f7 runtime: make ncgocall a global counter Change-Id: I1ce4a3b3ff7c824c67ad66dd27d9d5f1d25c0023
2021-06-25runtime: make ncgocall a global counterTao Qingyun
ncgocall was stored per M, runtime.NumCgoCall lost the counter when a M die. Fixes #46789 Change-Id: I85831fbb2713f4c30d1800d07e1f47aa0031970e GitHub-Last-Rev: cbc15fa870de776d3fbf3b62fc9a5e01792e6a26 GitHub-Pull-Request: golang/go#46842 Reviewed-on: https://go-review.googlesource.com/c/go/+/329729 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Alexander Rakoczy <alex@golang.org>
2021-06-17[dev.typeparams] runtime: fix import sort order [generated]Michael Anthony Knyszek
[git-generate] cd src/runtime goimports -w *.go Change-Id: I1387af0f2fd1a213dc2f4c122e83a8db0fcb15f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/329189 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17[dev.typeparams] runtime: replace uses of runtime/internal/sys.PtrSize with ↵Michael Anthony Knyszek
internal/goarch.PtrSize [generated] [git-generate] cd src/runtime/internal/math gofmt -w -r "sys.PtrSize -> goarch.PtrSize" . goimports -w *.go cd ../.. gofmt -w -r "sys.PtrSize -> goarch.PtrSize" . goimports -w *.go Change-Id: I43491cdd54d2e06d4d04152b3d213851b7d6d423 Reviewed-on: https://go-review.googlesource.com/c/go/+/328337 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-16[dev.typeparams] all: merge master (785a8f6) into dev.typeparamsCuong Manh Le
- test/run.go CL 328050 added fixedbugs/issue46749.go to -G=3 excluded files list Merge List: + 2021-06-16 785a8f677f cmd/compile: better error message for invalid untyped operation + 2021-06-16 a752bc0746 syscall: fix TestGroupCleanupUserNamespace test failure on Fedora + 2021-06-15 d77f4c0c5c net/http: improve some server docs + 2021-06-15 219fe9d547 cmd/go: ignore UTF8 BOM when reading source code + 2021-06-15 723f199edd cmd/link: set correct flags in .dynamic for PIE buildmode + 2021-06-15 4d2d89ff42 cmd/go, go/build: update docs to use //go:build syntax + 2021-06-15 033d885315 doc/go1.17: document go run pkg@version + 2021-06-15 ea8612ef42 syscall: disable c-shared test when no cgo, for windows/arm + 2021-06-15 abc56fd1a0 internal/bytealg: remove duplicate go:build line + 2021-06-15 4061d3463b syscall: rewrite handle inheritance test to use C rather than Powershell + 2021-06-15 cf4e3e3d3b reflect: explain why convertible or comparable types may still panic + 2021-06-14 7841cb14d9 doc/go1.17: assorted fixes + 2021-06-14 8a5a6f46dc debug/elf: don't apply DWARF relocations for ET_EXEC binaries + 2021-06-14 9d13f8d43e runtime: update the variable name in comment + 2021-06-14 0fd20ed5b6 reflect: use same conversion panic in reflect and runtime + 2021-06-14 6bbb0a9d4a cmd/internal/sys: mark windows/arm64 as c-shared-capable + 2021-06-14 d4f34f8c63 doc/go1.17: reword "results" in stack trace printing Change-Id: I60d1f67c4d48cd4093c350fc89bd60c454d23944
2021-06-14runtime: update the variable name in commentEric Wang
The comment use allg to refer to allgs in code. Update the comment to use the same variable name. Change-Id: Id059fce7846776737fb038b86bcf8765a4a7c9c0 GitHub-Last-Rev: 234fb0a208f105352d33456159725a3fce3a3071 GitHub-Pull-Request: golang/go#46723 Reviewed-on: https://go-review.googlesource.com/c/go/+/327629 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-11[dev.typeparams] runtime: simplify defer record allocationCherry Mui
Now that deferred functions are always argumentless and defer records are no longer with arguments, defer record can be fixed size (just the _defer struct). This allows us to simplify the allocation of defer records, specifically, remove the defer classes and the pools of different sized defers. Change-Id: Icc4b16afc23b38262ca9dd1f7369ad40874cf701 Reviewed-on: https://go-review.googlesource.com/c/go/+/326062 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11[dev.typeparams] runtime: allow newproc split stackCherry Mui
newproc was not allowed to split stack because it had a special stack layout, where the go'd function's arguments were passed on stack but not included in the signature (therefore the stack map). Now it no longer has argument, so it does not need to be nosplit. Change-Id: I6f39730fb1595c4b0438c74118fef418fe1c082b Reviewed-on: https://go-review.googlesource.com/c/go/+/325919 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-06-08[dev.typeparams] cmd/compile, runtime: remove the siz argument of ↵Cherry Mui
newproc/deferproc newproc/deferproc takes a siz argument for the go'd/deferred function's argument size. Now it is always zero. Remove the argument. Change-Id: If1bb8d427e34015ccec0ba10dbccaae96757fa8c Reviewed-on: https://go-review.googlesource.com/c/go/+/325917 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-08[dev.typeparams] runtime: remove variadic defer/go callsCherry Mui
Now that defer/go wrapping is used, deferred/go'd functions are always argumentless. Remove the code handling arguments. This CL is mostly removing the fallback code path. There are more cleanups to be done, in later CLs. Change-Id: I87bfd3fb2d759fbeb6487b8125c0f6992863d6e5 Reviewed-on: https://go-review.googlesource.com/c/go/+/325915 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-06-08[dev.typeparams] cmd/compile, runtime: always enable defer/go wrappingCherry Mui
Hardwire regabidefers to true. Remove it from GOEXPERIMENTs. Fallback paths are not cleaned up in this CL. That will be done in later CLs. Change-Id: Iec1112a1e55d5f6ef70232a5ff6e702f649071c4 Reviewed-on: https://go-review.googlesource.com/c/go/+/325913 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
2021-06-07[dev.typeparams] all: merge master (8212707) into dev.typeparamsMatthew Dempsky
Conflicts: - src/go/internal/gcimporter/iimport.go CL 325429 and CL 319931 made unrelated changes to adjacent lines Merge List: + 2021-06-07 8212707871 crypto/elliptic: update P-521 docs to say it's constant-time + 2021-06-07 7406180012 fmt: split package documentation into more sections + 2021-06-07 e3176bbc3e crypto/tls: fix typo in Config.NextProtos docs + 2021-06-05 e1fa26026d spec: improve wording consistency by eliminating "specifier" + 2021-06-05 f490134126 spec: improve wording by choosing an official term "keyword" + 2021-06-05 e3cb381704 go/internal/gcimporter: don't waste CPU copying bytes in `io.ReadAll` + 2021-06-05 9d669ed47a misc/cgo/errors: use expected column numbers + 2021-06-04 95939e8de7 cmd/compile/internal/abi: fix typo in comment + 2021-06-04 831f9376d8 net/http: fix ResponseWriter.ReadFrom with short reads + 2021-06-04 3a9d906edc os: avoid finalizer race in windows process object + 2021-06-04 105c5b50e0 os: terminate windows processes via handle directly + 2021-06-04 79cd407f88 syscall: regenerate zsyscall_windows.go + 2021-06-04 c6b6211229 doc/go1.17: document testing changes for Go 1.17 + 2021-06-04 0214440075 syscall: do not pass console handles to PROC_THREAD_ATTRIBUTE_HANDLE_LIST on Windows 7 + 2021-06-04 962d5c997a cmd/compile,go/types: restrict use of unsafe.{Add,Slice} to go1.17 or newer + 2021-06-04 b29b123e07 cmd/compile: remove spurious ir.Dump + 2021-06-03 6d98301114 cmd/link: use correct alignment in PE DWARF sections + 2021-06-03 e0d029f758 runtime: avoid gp.lockedm race in exitsyscall0 + 2021-06-02 dd7ba3ba2c net: don't rely on system hosts in TestCVE202133195 + 2021-06-02 4f572d7076 io/fs: minor corrections to Sub docs + 2021-06-02 e11d14225c doc/go1.17: remove runtime section + 2021-06-02 6e189afd3e doc/go1.17: mention SYS_WAIT6/WEXITED on NetBSD + 2021-06-02 ff9f5fb859 cmd/link: recognize clang linker error in testCGOLTO + 2021-06-02 1c6a2ea2ea doc/go1.17: document time changes for Go1.17 + 2021-06-02 d743e67e06 doc/go1.17: document flag changes for Go 1.17 + 2021-06-02 dc8f87b749 runtime/internal/sys: generate //go:build lines in gengoos.go + 2021-06-02 84c0e5d47f cmd/link: move issue 43830 tests out of TestScript + 2021-06-02 cae68700cc runtime: fix formatting + 2021-06-01 567ee865f6 cmd/go: add declaration to cgo_lto_issue43830 test + 2021-06-01 24e9707cbf cmd/link, cmd/cgo: support -flto in CFLAGS Change-Id: I9ef88e7de0f8b1841ed9604b613b41672df67e71
2021-06-03runtime: avoid gp.lockedm race in exitsyscall0Michael Pratt
Following https://golang.org/cl/291329, exitsyscall0 accesses gp.lockedm after releasing gp to the global runq. This creates a race window where another M may schedule the (unlocked) G, which subsequently calls LockOSThread, setting gp.lockedm and thus causing exitsyscall0 to think it should call stoplockedm. Avoid this race by checking if gp is locked before releasing it to the global runq. Fixes #46524 Change-Id: I3acdaf09e7a2178725adbe61e985130e9ebd0680 Reviewed-on: https://go-review.googlesource.com/c/go/+/324350 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-21[dev.typeparams] runtime: replace funcPC with internal/abi.FuncPCABIInternalCherry Mui
At this point all funcPC references are ABIInternal functions. Replace with the intrinsics. Change-Id: I3ba7e485c83017408749b53f92877d3727a75e27 Reviewed-on: https://go-review.googlesource.com/c/go/+/321954 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-21[dev.typeparams] runtime: fix misuse of funcPCCherry Mui
funcPC expects a func value. There are places where we pass an unsafe.Pointer, which is technically undefined. In proc.go it is actually representing a func value, so the expression does the right thing. Cast to a func value so it is clearer. In os_freebsd.go it is a raw function pointer. Using funcPC on a raw function pointer is incorrect. Just use it directly instead. Change-Id: I3c5d61cea08f0abf5737834b520f9f1b583c1d34 Reviewed-on: https://go-review.googlesource.com/c/go/+/321953 Trust: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-21[dev.typeparams] runtime: use internal/abi.FuncPCABI0 to reference ABI0 ↵Cherry Mui
assembly symbols Use FuncPCABI0 to reference ABI0 assembly symbols. Currently, they are referenced using funcPC, which will get the ABI wrapper's address. They don't seem to affect correctness (either the wrapper is harmless, or, on non-AMD64 architectures, not enabled). They should have been converted. This CL does not yet completely eliminate funcPC. But at this point we should be able to replace all remaining uses of funcPC to internal/abi.FuncPCABIInternal. Change-Id: I383a686e11d570f757f185fe46769a42c856ab77 Reviewed-on: https://go-review.googlesource.com/c/go/+/321952 Trust: Cherry Mui <cherryyz@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-05-12runtime: fix handling of SPWRITE functions in tracebackRuss Cox
It is valid to see SPWRITE functions at the top of a GC stack traceback, in the case where they self-preempted during the stack growth check and haven't actually modified SP in a traceback-unfriendly manner yet. The current check is therefore too aggressive. isAsyncSafePoint is taking care of not async-preempting SPWRITE functions because it doesn't async-preempt any assembly functions at all. But perhaps it will in the future. To keep a check that SPWRITE assembly functions are not async-preempted, add one in preemptPark. Then relax the check in traceback to avoid triggering on self-preempted SPWRITE functions. The long and short of this is that the assembly we corrected in x/crypto issue #44269 was incredibly dodgy but not technically incompatible with the Go runtime. After this change, the original x/crypto assembly no longer causes GC traceback crashes during "GOGC=1 go test -count=1000". But we'll still leave the corrected assembly. This also means that we don't need to worry about diagnosing SPWRITE assembly functions that may exist in the wild. They will be skipped for async preemption and no harm no foul. Fixes #44269, which was open pending some kind of check for bad SPWRITE functions in the wild. (No longer needed.) Change-Id: I6000197b62812bbd2cd92da28eab422634cf75a8 Reviewed-on: https://go-review.googlesource.com/c/go/+/317669 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-12runtime: fix typo in proc.goGuilherme Souza
Change-Id: I12c0befc5772a5c902a55aeb06a30ec7a34a3bd6 GitHub-Last-Rev: 7d41e1bcb9f6304e1b868701740279e845c99a66 GitHub-Pull-Request: golang/go#46112 Reviewed-on: https://go-review.googlesource.com/c/go/+/319053 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-05-11runtime: hold sched.lock across atomic pidleget/pidleputMichael Pratt
As a cleanup, golang.org/cl/307914 unintentionally caused the idle GC work recheck to drop sched.lock between acquiring a P and committing to keep it (once a worker G was found). This is unsafe, as releasing a P requires extra checks once sched.lock is taken (such as for runSafePointFn). Since checkIdleGCNoP does not perform these extra checks, we can now race with other users. In the case of #45975, we may hang with this sequence: 1. M1: checkIdleGCNoP takes sched.lock, gets P1, releases sched.lock. 2. M2: forEachP takes sched.lock, iterates over sched.pidle without finding P1, releases sched.lock. 3. M1: checkIdleGCNoP puts P1 back in sched.pidle. 4. M2: forEachP waits forever for P1 to run the safePointFn. Change back to the old behavior of releasing sched.lock only after we are certain we will keep the P. Thus if we put it back its removal from sched.pidle was never visible. Fixes #45975 For #45916 For #45885 For #45884 Change-Id: I191a1800923b206ccaf96bdcdd0bfdad17b532e9 Reviewed-on: https://go-review.googlesource.com/c/go/+/318569 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com>
2021-05-09runtime: switch runtime to libc for openbsd/armJoel Sing
Use libc rather than performing direct system calls for the runtime on openbsd/arm. Updates #36435 Change-Id: If64a96a61c80b9748792f8a85a8f16ed6ebca91f Reviewed-on: https://go-review.googlesource.com/c/go/+/315792 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-09runtime: switch openbsd/arm to pthreadsJoel Sing
This switches openbsd/arm to thread creation via pthreads, rather than doing direct system calls. Update #36435 Change-Id: Ia8749e3723a9967905c33b6d93dfd9be797a486c Reviewed-on: https://go-review.googlesource.com/c/go/+/315790 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-05-05runtime: implement runqdrain() for GC mark worker goroutinesAndy Pan
Revive CL 310149 Change-Id: Ib4714ea5b2ade32c0f66edff841a79d8212bd79a Reviewed-on: https://go-review.googlesource.com/c/go/+/313009 Run-TryBot: Ian Lance Taylor <iant@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com>
2021-04-30runtime: switch runtime to libc for openbsd/386Joel Sing
Use libc rather than performing direct system calls for the runtime on openbsd/386. Updates #36435 Change-Id: I0cd65368bc824c81f5f98ea24e4f82db5468b170 Reviewed-on: https://go-review.googlesource.com/c/go/+/287653 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-30runtime: switch openbsd/386 to pthreadsJoel Sing
This switches openbsd/386 to thread creation via pthreads, rather than doing direct system calls. Update #36435 Change-Id: I000a815fc0edd0272c3285954f3f007229bc60a0 Reviewed-on: https://go-review.googlesource.com/c/go/+/250577 Trust: Joel Sing <joel@sing.id.au> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-04-23cmd/compile, internal/abi: add FuncPCABIxxx intrinsicsCherry Zhang
When ABI wrappers are used, there are cases where in Go code we need the PC of the defined function instead of the ABI wrapper. Currently we work around this by define such functions as ABIInternal, even if they do not actually follow the internal ABI. This CL introduces internal/abi.FuncPCABIxxx functions as compiler intrinsics, which return the underlying defined function's entry PC if the argument is a direct reference of a function of the expected ABI, and reject it if it is of a different ABI. As a proof of concept, change runtime.goexit back to ABI0 and use internal/abi.FuncPCABI0 to retrieve its PC. Updates #44065. Change-Id: I02286f0f9d99e6a3090f9e8169dbafc6804a2da6 Reviewed-on: https://go-review.googlesource.com/c/go/+/304232 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2021-04-23runtime,runtime/metrics: add metric to track scheduling latenciesMichael Pratt
This change adds a metric to track scheduling latencies, defined as the cumulative amount of time a goroutine spends being runnable before running again. The metric is an approximations and samples instead of trying to record every goroutine scheduling latency. This change was primarily authored by mknyszek@google.com. Change-Id: Ie0be7e6e7be421572eb2317d3dd8dd6f3d6aa152 Reviewed-on: https://go-review.googlesource.com/c/go/+/308933 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-22runtime: skip work recheck for non-spinning MsMichael Pratt
When an M transitions from spinning to non-spinning state, it must recheck most sources of work to avoid missing work submitted between its initial check and decrementing sched.nmspinning (see "delicate dance" comment). Ever since the scheduler rewrite in Go 1.1 (golang.org/cl/7314062), we have performed this recheck on all Ms before stopping, regardless of whether or not they were spinning. Unfortunately, there is a problem with this approach: non-spinning Ms are not eligible to steal work (note the skip over the stealWork block), but can detect work during the recheck. If there is work available, this non-spinning M will jump to top, skip stealing, land in recheck again, and repeat. i.e., it will spin uselessly. The spin is bounded. This can only occur if there is another spinning M, which will either take the work, allowing this M to stop, or take some other work, allowing this M to upgrade to spinning. But the spinning is ultimately just a fancy spin-wait. golang.org/issue/43997 discusses several ways to address this. This CL takes the simplest approach: skipping the recheck on non-spinning Ms and allowing them to go to stop. Results for scheduler-relevant runtime and time benchmarks can be found at https://perf.golang.org/search?q=upload:20210420.5. The new BenchmarkCreateGoroutinesSingle is a characteristic example workload that hits this issue hard. A single M readies lots of work without itself parking. Other Ms must spin to steal work, which is very short-lived, forcing those Ms to spin again. Some of the Ms will be non-spinning and hit the above bug. With this fixed, that benchmark drops in CPU usage by a massive 68%, and wall time 24%. BenchmarkNetpollBreak shows similar drops because it is unintentionally almost the same benchmark (create short-living Gs in a loop). Typical well-behaved programs show little change. We also measure scheduling latency (time from goready to execute). Note that many of these benchmarks are very noisy because they don't involve much scheduling. Those that do, like CreateGoroutinesSingle, are expected to increase as we are replacing unintentional spin waiting with a real park. Fixes #43997 Change-Id: Ie1d1e1800f393cee1792455412caaa5865d13562 Reviewed-on: https://go-review.googlesource.com/c/go/+/310850 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-21syscall: syscall.AllThreadsSyscall signal handling fixesAndrew G. Morgan
The runtime support for syscall.AllThreadsSyscall() functions had some corner case deadlock issues when signal handling was in use. This was observed in at least 3 build test failures on ppc64 and amd64 architecture CGO_ENABLED=0 builds over the last few months. The fixes involve more controlled handling of signals while the AllThreads mechanism is being executed. Further details are discussed in bug #44193. The all-threads syscall support is new in go1.16, so earlier releases are not affected by this bug. Fixes #44193 Change-Id: I01ba8508a6e1bb2d872751f50da86dd07911a41d Reviewed-on: https://go-review.googlesource.com/c/go/+/305149 Reviewed-by: Michael Pratt <mpratt@google.com> Trust: Michael Pratt <mpratt@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-21runtime: move timer recheck after GC recheckMichael Pratt
When rechecking for work after transitioning from a spinning to non-spinning M, checking timers before GC isn't useful. That is, if there is GC work available, it will run immediately and the updated pollUntil is unused. Move this check to just before netpoll, where pollUntil is used. While this technically improves efficiency in the (rare) case that we find GC work in this block, the primary motivation is simply to improve clarity by moving the update closer to use. For #43997 Change-Id: Ibc7fb308ac4a582875c200659c9e272121a89f3b Reviewed-on: https://go-review.googlesource.com/c/go/+/308654 Trust: Michael Pratt <mpratt@google.com> Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-20Revert "runtime: implement runqdrain() for GC mark worker goroutines"Ian Lance Taylor
This reverts CL 310149. Reason for revert: Breaks longtest builders: https://build.golang.org/log/6af9fb147fa3101154db10e7ce055e8267cd4c93 https://build.golang.org/log/172ed6e1ec3bb503370333ee421c590fd2a72d0a Change-Id: Iaf5a8b9eec51d0517311e050d0b0f7569759d292 Reviewed-on: https://go-review.googlesource.com/c/go/+/312129 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20runtime: refactor findrunnable spinning recheckMichael Pratt
Break the main components of the findrunnable spinning -> non-spinning recheck out into their own functions, which simplifies both findrunnable and the new functions, which can make use of fancy features like early returns. This CL should have no functional changes. For #43997 For #44313 Change-Id: I6d3060fcecda9920a3471ff338f73d53b1d848a3 Reviewed-on: https://go-review.googlesource.com/c/go/+/307914 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-20runtime: implement runqdrain() for GC mark worker goroutinesAndy Pan
Change-Id: Ida44a2e07f277bee8806538ecee4beee3474cf3d Reviewed-on: https://go-review.googlesource.com/c/go/+/310149 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Michael Pratt <mpratt@google.com> Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-04-20runtime: refactor work stealing to dedicated functionMichael Pratt
findrunnable has grown very large and hard to follow over the years. Parts we can split out into logical chunks should help make it more understandable and easier to change in the future. The work stealing loop is one such big chunk that is fairly trivial to split out into its own function, and even has the advantage of simplifying control flow by removing a goto around work stealing. This CL should have no functional changes. For #43997. For #44313. Change-Id: Ie69670c7bc60bd6c114e860184918717829adb22 Reviewed-on: https://go-review.googlesource.com/c/go/+/307913 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Chris Hines <chris.cs.guy@gmail.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-16runtime: clarify which work needs spinning coordinationMichael Pratt
The overview comments discuss readying goroutines, which is the most common source of work, but timers and idle-priority GC work also require the same synchronization w.r.t. spinning Ms. This CL should have no functional changes. For #43997 Updates #44313 Change-Id: I7910a7f93764dde07c3ed63666277eb832bf8299 Reviewed-on: https://go-review.googlesource.com/c/go/+/307912 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-16runtime: remove redudant tryWakeP componentMichael Pratt
Here tryWakeP can't already be true, so there is no need to combine the values. This CL should have no functional changes. For #43997. For #44313. Change-Id: I640c7bb88a5f70c8d22f89f0b5b146b3f60c0136 Reviewed-on: https://go-review.googlesource.com/c/go/+/307911 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-16runtime: move findrunnable timer delay computation closer to useMichael Pratt
findrunnable has a couple places where delta is recomputed from a new pollUntil value. This proves to be a pain in refactoring, as it is easy to forget to do properly. Move computation of delta closer to its use, where it is more logical anyways. This CL should have no functional changes. For #43997. For #44313. Change-Id: I89980fd7f40f8a4c56c7540cae03ff99e12e1422 Reviewed-on: https://go-review.googlesource.com/c/go/+/307910 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-11runtime: move zero-sized frame check from newproc to newproc1Austin Clements
If GOEXPERIMENT=regabidefer is enabled, newproc currently checks that the call frame for new goroutines is empty. But there's one place in the runtime (debugCallWrap), where we call newproc1, and it happens to pass a non-empty frame. The current check didn't catch that. Move the empty call frame check from newproc to newproc1 to catch this. Updates #40724. Change-Id: I9998faf1e07e7b7af88e06a8177127f998c40252 Reviewed-on: https://go-review.googlesource.com/c/go/+/309034 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-04-08runtime,cmd/link: include GOEXPERIMENTs in runtime.Version(), "go version X"Austin Clements
This adds the set of GOEXPERIMENTs to the build version if it differs from the default set of experiments. This exposes the experiment settings via runtime.Version() and "go version <binary>". Change-Id: I143dbbc50f66a4cf175469199974e18848075af6 Reviewed-on: https://go-review.googlesource.com/c/go/+/307820 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08internal/goexperiment: consolidate experiment-enabled constantsAustin Clements
Currently, we have boolean and integral constants for GOEXPERIMENTs in various places. Consolidate these into automatically generated constants in the internal/goexperiment package. Change-Id: I42a49aba2a3b4c722fedea23a613162cd8a67bee Reviewed-on: https://go-review.googlesource.com/c/go/+/307818 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-08runtime: drop haveexperiment, sys.GOEXPERIMENTAustin Clements
We have ways to statically access experiments now, so we don't need a relatively clunky string-parsing dynamic way to do it. Change-Id: I5d75480916eef4bde2c30d5fe30593180da77ff2 Reviewed-on: https://go-review.googlesource.com/c/go/+/307815 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-04-01runtime: fix uses of ABIInternal PCs in assemblyAustin Clements
The covers three kinds of uses: 1. Calls of closures from assembly. These are always ABIInternal calls without wrappers. I went through every indirect call in the runtime and I think mcall is the only case of assembly calling a Go closure in a way that's affected by ABIInternal. systemstack also calls a closure, but it takes no arguments. 2. Calls of Go functions that expect raw ABIInternal pointers. I also only found one of these: callbackasm1 -> cgocallback on Windows. These are trickier to find, though. 3. Finally, I found one case on NetBSD where new OS threads were directly calling the Go runtime entry-point from assembly via a PC, rather than going through a wrapper. This meant new threads may not have special registers set up. In this case, a change on all other OSes had already forced new thread entry to go through an ABI wrapper, so I just caught NetBSD up with that change. With this change, I'm able to run a "hello world" with GOEXPERIMENT=regabi,regabiargs. For #40724. Change-Id: I2a6d0e530c4fd4edf13484d923891c6160d683aa Reviewed-on: https://go-review.googlesource.com/c/go/+/305669 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-30runtime: fix G passed to schedEnabled and cleanupMichael Pratt
exitsyscall0 contains two G variables: _g_ and gp. _g_ is the active G, g0, while gp is the G to run (which just exited from a syscall). It is passing _g_ to schedEnabled, which is incorrect; we are about to execute gp, so that is what we should be checking the schedulability of. While this is incorrect and should be fixed, I don't think it has ever caused a problem in practice: * g0 does not have g.startpc set, so schedEnabled simplifies to just !sched.disable.user. * This is correct provided gp is never a system goroutine. * As far as I know, system goroutines never use entersyscall / exitsyscall. As far I can tell, this was a simple copy/paste error from exitsyscall, where variable _g_ is the G to run. While we are here, eliminate _g_ entirely, as the one other use is identical to using gp. Change-Id: I5df98a34569238b89ab13ff7012cd756fefb10dc Reviewed-on: https://go-review.googlesource.com/c/go/+/291329 Trust: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2021-03-30runtime: check that defer/go frames are emptyAustin Clements
With GOEXPERIMENT=regabidefer, these frames should always be empty. Check that. For #40724. Change-Id: Id8e418a9e06b4f94543cb16b868a7e10e013c2d9 Reviewed-on: https://go-review.googlesource.com/c/go/+/306009 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-29runtime: fix some typos徐志伟
Change-Id: I31f2081eb7c30a9583f479f9194e636fe721b9b3 GitHub-Last-Rev: d09f5fbdc5785dc3963b22ad75309740e0de258e GitHub-Pull-Request: golang/go#45278 Reviewed-on: https://go-review.googlesource.com/c/go/+/305231 Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-29runtime: fix some typosqcrao
Change-Id: I18b9508904f19d5aa68355c937c30b5fdf35442c Reviewed-on: https://go-review.googlesource.com/c/go/+/305249 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-24runtime: bypass ABI wrapper when calling needm on WindowsMichael Anthony Knyszek
On Windows, when calling into needm in cgocallback on a new thread that is unknown to the Go runtime, we currently call through an ABI wrapper. The ABI wrapper tries to restore the G register from TLS. On other platforms, TLS is set up just enough that the wrapper will simply load a nil g from TLS, but on Windows TLS isn't set up at all, so there's nowhere for the wrapper to load from. So, bypass the wrapper in the call to needm. needm takes no arguments and returns no results so there are no special ABI considerations, except that we must clear X15 which is used as a zero register in Go code (a function normally performed by the ABI wrapper). needm is also otherwise already special and carefully crafted to avoid doing anything that would require a valid G or M, at least until it is able to create one. While we're here, this change simplifies setg so that it doesn't set up TLS on Windows and instead provides an OS-specific osSetupTLS to do that. The result of this is that setg(nil) no longer clears the TLS space pointer on Windows. There's exactly one place this is used (dropm) where it doesn't matter anymore, and an empty TLS means that setg's wrapper will crash on the return path. Another result is that the G slot in the TLS will be properly cleared, however, which isn't true today. For #40724. Change-Id: I65c3d924a3b16abe667b06fd91d467d6d5da31d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/303070 Trust: Michael Knyszek <mknyszek@google.com> Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-18cmd/internal/objabi,runtime: simplify sys.GOEXPERIMENT parsingAustin Clements
Previously, the runtime had to understand the full syntax of the GOEXPERIMENT environment variable. Now, sys.GOEXPERIMENT is the pre-processed experiment list produced by objabi, so we can simplify the runtime parser. Change-Id: I0d113a4347dde50a35b8b1f2b0110c88fe802921 Reviewed-on: https://go-review.googlesource.com/c/go/+/303049 Trust: Austin Clements <austin@google.com> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
2021-03-13all: remove duplicate wordsJohn Bampton
Change-Id: Ib0469232a2b69a869e58d5d24990ad74ac96ea56 GitHub-Last-Rev: eb38e049ee1e773392ff3747e1eb2af20dd50dcd GitHub-Pull-Request: golang/go#44805 Reviewed-on: https://go-review.googlesource.com/c/go/+/299109 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>