Skip to content

Commit 6406227

Browse files
committed
runtime: skip sysmon workaround on NetBSD >= 9.2
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 <[email protected]> Trust: Benny Siegert <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> Reviewed-by: Michael Pratt <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]>
1 parent a05a7d4 commit 6406227

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/runtime/os_netbsd.go

+11
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ var sigset_all = sigset{[4]uint32{^uint32(0), ^uint32(0), ^uint32(0), ^uint32(0)
101101

102102
// From NetBSD's <sys/sysctl.h>
103103
const (
104+
_CTL_KERN = 1
105+
_KERN_OSREV = 3
106+
104107
_CTL_HW = 6
105108
_HW_NCPU = 3
106109
_HW_PAGESIZE = 7
@@ -138,6 +141,13 @@ func getPageSize() uintptr {
138141
return 0
139142
}
140143

144+
func getOSRev() int {
145+
if osrev, ok := sysctlInt([]uint32{_CTL_KERN, _KERN_OSREV}); ok {
146+
return int(osrev)
147+
}
148+
return 0
149+
}
150+
141151
//go:nosplit
142152
func semacreate(mp *m) {
143153
}
@@ -252,6 +262,7 @@ func osinit() {
252262
if physPageSize == 0 {
253263
physPageSize = getPageSize()
254264
}
265+
needSysmonWorkaround = getOSRev() < 902000000 // NetBSD 9.2
255266
}
256267

257268
var urandom_dev = []byte("/dev/urandom\x00")

src/runtime/proc.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -5229,6 +5229,10 @@ func checkdead() {
52295229
// This is a variable for testing purposes. It normally doesn't change.
52305230
var forcegcperiod int64 = 2 * 60 * 1e9
52315231

5232+
// needSysmonWorkaround is true if the workaround for
5233+
// golang.org/issue/42515 is needed on NetBSD.
5234+
var needSysmonWorkaround bool = false
5235+
52325236
// Always runs without a P, so write barriers are not allowed.
52335237
//
52345238
//go:nowritebarrierrec
@@ -5337,7 +5341,7 @@ func sysmon() {
53375341
}
53385342
}
53395343
mDoFixup()
5340-
if GOOS == "netbsd" {
5344+
if GOOS == "netbsd" && needSysmonWorkaround {
53415345
// netpoll is responsible for waiting for timer
53425346
// expiration, so we typically don't have to worry
53435347
// about starting an M to service timers. (Note that

0 commit comments

Comments
 (0)