aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/netpoll_stub.go
AgeCommit message (Collapse)Author
2021-02-20all: go fmt std cmd (but revert vendor)Russ Cox
Make all our package sources use Go 1.17 gofmt format (adding //go:build lines). Part of //go:build change (#41184). See https://golang.org/design/draft-gobuild Change-Id: Ia0534360e4957e58cd9a18429c39d0e32a6addb4 Reviewed-on: https://go-review.googlesource.com/c/go/+/294430 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-14runtime: avoid lock starvation in TestNetpollBreak on Plan 9Richard Miller
TestNetpollBreak was sometimes timing out on Plan 9, where netpoll_stub.go implements only enough of the network poller to support runtime timers, using a notetsleep / notewakeup pair. The runtime.lock which serialises the use of the note doesn't guarantee fairness, and in practice the netpoll call used by the test can be starved by the netpoll call from the scheduler which supports the overall 'go test' timeout. Calling osyield after relinquishing the lock gives the two callers a more even chance to take a turn, which prevents the test from timing out. Fixes #39437 Change-Id: Ifbe6aaf95336d162d9d0b6deba19b8debf17b071 Reviewed-on: https://go-review.googlesource.com/c/go/+/237698 Run-TryBot: David du Colombier <0intro@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-02-07runtime: avoid double notewakeup in netpoll stub codeIan Lance Taylor
Otherwise we can see - goroutine 1 calls netpollBreak, the atomic.Cas succeeds, then suspends - goroutine 2 calls noteclear, sets netpollBroken to 0 - goroutine 3 calls netpollBreak, the atomic.Cas succeeds, calls notewakeup - goroutine 1 wakes up calls notewakeup, crashes due to double wakeup This doesn't happen on Plan 9 because it only runs one thread at a time. But Fuschia wants to use this code too. Change-Id: Ib636e4f327bb15e44a2c40fd681aae9a91073a30 Reviewed-on: https://go-review.googlesource.com/c/go/+/218537 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-30runtime: record stub netpoll initialization, add lock around noteIan Lance Taylor
This fixes the Plan 9 support for the new timer code. Updates #6239 Updates #27707 Change-Id: Ia498c399b8924910b97fcde07545fae3588aad47 Reviewed-on: https://go-review.googlesource.com/c/go/+/204045 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-22runtime: add new addtimer functionIan Lance Taylor
When we add a timer, make sure that the network poller is initialized, since we will use it if we have to wait for the timer to be ready. Updates #27707 Change-Id: I0637fe646bade2cc5ce50b745712292aa9c445b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/171830 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-21runtime: add netpollBreakIan Lance Taylor
The new netpollBreak function can be used to interrupt a blocking netpoll. This function is not currently used; it will be used by later CLs. Updates #27707 Change-Id: I5cb936609ba13c3c127ea1368a49194fc58c9f4d Reviewed-on: https://go-review.googlesource.com/c/go/+/171824 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2019-10-15runtime: change netpoll to take an amount of time to blockIan Lance Taylor
This new facility will be used by future CLs in this series. Change the only blocking call to netpoll to do the right thing when netpoll returns an empty list. Updates #6239 Updates #27707 Change-Id: I58b3c2903eda61a3698b1a4729ed0e81382bb1ed Reviewed-on: https://go-review.googlesource.com/c/go/+/171821 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2018-08-20runtime: use gList in netpollAustin Clements
netpoll is perhaps one of the most confusing uses of G lists currently since it passes around many lists as bare *g values right now. Switching to gList makes it much clearer what's an individual g and what's a list. Change-Id: I8d8993c4967c5bae049c7a094aad3a657928ba6c Reviewed-on: https://go-review.googlesource.com/129397 Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Rick Hudson <rlh@golang.org>
2017-02-15os: use poller for file I/OIan Lance Taylor
This changes the os package to use the runtime poller for file I/O where possible. When a system call blocks on a pollable descriptor, the goroutine will be blocked on the poller but the thread will be released to run other goroutines. When using a non-pollable descriptor, the os package will continue to use thread-blocking system calls as before. For example, on GNU/Linux, the runtime poller uses epoll. epoll does not support ordinary disk files, so they will continue to use blocking I/O as before. The poller will be used for pipes. Since this means that the poller is used for many more programs, this modifies the runtime to only block waiting for the poller if there is some goroutine that is waiting on the poller. Otherwise, there is no point, as the poller will never make any goroutine ready. This preserves the runtime's current simple deadlock detection. This seems to crash FreeBSD systems, so it is disabled on FreeBSD. This is issue 19093. Using the poller on Windows requires opening the file with FILE_FLAG_OVERLAPPED. We should only do that if we can remove that flag if the program calls the Fd method. This is issue 19098. Update #6817. Update #7903. Update #15021. Update #18507. Update #19093. Update #19098. Change-Id: Ia5197dcefa7c6fbcca97d19a6f8621b2abcbb1fe Reviewed-on: https://go-review.googlesource.com/36800 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-14runtime: define netpollinited on Plan 9David du Colombier
Since CL 2750, the build is broken on Plan 9, because a new function netpollinited was added and called from findrunnable in proc1.go. However, netpoll is not implemented on Plan 9. Thus, we define netpollinited in netpoll_stub.go. Fixes #9590 Change-Id: I0895607b86cbc7e94c1bfb2def2b1a368a8efbe6 Reviewed-on: https://go-review.googlesource.com/2759 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2014-11-21[dev.cc] runtime: convert Plan 9 port to GoDavid du Colombier
Thanks to Aram Hăvărneanu, Nick Owens and Russ Cox for the early reviews. LGTM=aram, rsc R=rsc, lucio.dere, aram, ality CC=golang-codereviews, mischief https://golang.org/cl/175370043