aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorKir Kolyshkin <kolyshkin@gmail.com>2025-09-03 16:12:39 -0700
committerKirill Kolyshkin <kolyshkin@gmail.com>2025-09-15 11:46:39 -0700
commit68c6a73380e82a0ea9a93c1a75ab8a38f28f3a3d (patch)
tree982a853333f6f068ef77bfb16d9cef97dac60a7c /src/runtime
parente603e9834e83ec67f0dd39c4e77683eef0593946 (diff)
downloadgo-68c6a73380e82a0ea9a93c1a75ab8a38f28f3a3d.tar.xz
internal/syscall/unix: add KernelVersionGE
There are a few places in the code which checks that the running kernel is greater than or equal to x.y. The check takes a few lines and the checking code is somewhat distracting. Let's abstract this check into a simple function, KernelVersionGE, and convert the users accordingly. Add a test case (I'm not sure it has much value, can be dropped). Change-Id: I8ec91dcc7452363361f95e46794701c0ae57d956 Reviewed-on: https://go-review.googlesource.com/c/go/+/700796 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Damien Neil <dneil@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/pprof/pprof_test.go10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/runtime/pprof/pprof_test.go b/src/runtime/pprof/pprof_test.go
index 99c5155806..25a2f3b324 100644
--- a/src/runtime/pprof/pprof_test.go
+++ b/src/runtime/pprof/pprof_test.go
@@ -117,10 +117,6 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) {
t.Skip("issue 35057 is only confirmed on Linux")
}
- // Linux [5.9,5.16) has a kernel bug that can break CPU timers on newly
- // created threads, breaking our CPU accounting.
- major, minor := unix.KernelVersion()
- t.Logf("Running on Linux %d.%d", major, minor)
defer func() {
if t.Failed() {
t.Logf("Failure of this test may indicate that your system suffers from a known Linux kernel bug fixed on newer kernels. See https://golang.org/issue/49065.")
@@ -131,9 +127,9 @@ func TestCPUProfileMultithreadMagnitude(t *testing.T) {
// it enabled to potentially warn users that they are on a broken
// kernel.
if testenv.Builder() != "" && (runtime.GOARCH == "386" || runtime.GOARCH == "amd64") {
- have59 := major > 5 || (major == 5 && minor >= 9)
- have516 := major > 5 || (major == 5 && minor >= 16)
- if have59 && !have516 {
+ // Linux [5.9,5.16) has a kernel bug that can break CPU timers on newly
+ // created threads, breaking our CPU accounting.
+ if unix.KernelVersionGE(5, 9) && !unix.KernelVersionGE(5, 16) {
testenv.SkipFlaky(t, 49065)
}
}