mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
systrap: don't call Goyield() if the race detector is enabled
Before this change: BM_Getpid 290875 ns 80000 ns 7000 After this change: BM_Getpid 20114 ns 5400 ns 116667 Reported-by: syzbot+b65fd5695fdb97a59033@syzkaller.appspotmail.com PiperOrigin-RevId: 532262444
This commit is contained in:
@@ -53,6 +53,8 @@ go_library(
|
||||
"lib_amd64.s",
|
||||
"lib_arm64.s",
|
||||
"shared_context.go",
|
||||
"shared_context_norace.go",
|
||||
"shared_context_race.go",
|
||||
"stub_amd64.s",
|
||||
"stub_arm64.s",
|
||||
"stub_defs.go",
|
||||
|
||||
@@ -23,7 +23,6 @@ import (
|
||||
"golang.org/x/sys/unix"
|
||||
"gvisor.dev/gvisor/pkg/sentry/platform"
|
||||
"gvisor.dev/gvisor/pkg/sentry/platform/systrap/sysmsg"
|
||||
gsync "gvisor.dev/gvisor/pkg/sync"
|
||||
"gvisor.dev/gvisor/pkg/syncevent"
|
||||
)
|
||||
|
||||
@@ -351,7 +350,7 @@ func (q *fastPathDispatcher) loop(target *sharedContext) {
|
||||
// q.list has to be empty at the end.
|
||||
continue
|
||||
}
|
||||
gsync.Goyield()
|
||||
yield()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build !race
|
||||
// +build !race
|
||||
|
||||
package systrap
|
||||
|
||||
import (
|
||||
"gvisor.dev/gvisor/pkg/sync"
|
||||
)
|
||||
|
||||
func yield() {
|
||||
sync.Goyield()
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
// Copyright 2023 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
//go:build race
|
||||
// +build race
|
||||
|
||||
package systrap
|
||||
|
||||
// yield is just a stub because sync.Goyield() is very expensive with the race
|
||||
// detector.
|
||||
func yield() {}
|
||||
Reference in New Issue
Block a user