]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: skip sysmon workaround on NetBSD >= 9.2
authorTobias Klauser <tklauser@distanz.ch>
Thu, 3 Jun 2021 14:57:54 +0000 (16:57 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Mon, 16 Aug 2021 21:24:44 +0000 (21:24 +0000)
Detect the NetBSD version in osinit and only enable the workaround for
the kernel bug identified in #42515 for NetBSD versions older than 9.2.

For #42515
For #46495

Change-Id: I808846c7f8e47e5f7cc0a2f869246f4bd90d8e22
Reviewed-on: https://go-review.googlesource.com/c/go/+/324472
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

src/runtime/os_netbsd.go
src/runtime/proc.go

index 2c20ee21734435c97ad985ee72738bebff187817..0b95fa7a6e75c77fe49c3a535fee7d14a4472eaf 100644 (file)
@@ -101,6 +101,9 @@ var sigset_all = sigset{[4]uint32{^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)
 
 // From NetBSD's <sys/sysctl.h>
 const (
+       _CTL_KERN   = 1
+       _KERN_OSREV = 3
+
        _CTL_HW        = 6
        _HW_NCPU       = 3
        _HW_PAGESIZE   = 7
@@ -138,6 +141,13 @@ func getPageSize() uintptr {
        return 0
 }
 
+func getOSRev() int {
+       if osrev, ok := sysctlInt([]uint32{_CTL_KERN, _KERN_OSREV}); ok {
+               return int(osrev)
+       }
+       return 0
+}
+
 //go:nosplit
 func semacreate(mp *m) {
 }
@@ -252,6 +262,7 @@ func osinit() {
        if physPageSize == 0 {
                physPageSize = getPageSize()
        }
+       needSysmonWorkaround = getOSRev() < 902000000 // NetBSD 9.2
 }
 
 var urandom_dev = []byte("/dev/urandom\x00")
index cde1a115830faacba3c71ba2c75184849457feb1..c2e43ef5c3748eb9657d844bd5d3492ed0992aec 100644 (file)
@@ -5229,6 +5229,10 @@ func checkdead() {
 // This is a variable for testing purposes. It normally doesn't change.
 var forcegcperiod int64 = 2 * 60 * 1e9
 
+// needSysmonWorkaround is true if the workaround for
+// golang.org/issue/42515 is needed on NetBSD.
+var needSysmonWorkaround bool = false
+
 // Always runs without a P, so write barriers are not allowed.
 //
 //go:nowritebarrierrec
@@ -5337,7 +5341,7 @@ func sysmon() {
                        }
                }
                mDoFixup()
-               if GOOS == "netbsd" {
+               if GOOS == "netbsd" && needSysmonWorkaround {
                        // netpoll is responsible for waiting for timer
                        // expiration, so we typically don't have to worry
                        // about starting an M to service timers. (Note that