summaryrefslogtreecommitdiffhomepage
path: root/pkg/sync/BUILD
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2020-11-19 14:27:17 -0800
committergVisor bot <gvisor-bot@google.com>2020-11-19 14:29:34 -0800
commit3454d572199679d6abc66c0c29539829dd9baf51 (patch)
tree64117492d2a3b96b94e707a1d56c519616a97b0b /pkg/sync/BUILD
parent27ee4fe76ad586ac8751951a842b3681f9375025 (diff)
Require sync.Mutex to lock and unlock from the same goroutine
We would like to track locks ordering to detect ordering violations. Detecting violations is much simpler if mutexes must be unlocked by the same goroutine that locked them. Thus, as a first step to tracking lock ordering, add this lock/unlock requirement to gVisor's sync.Mutex. This is more strict than the Go standard library's sync.Mutex, but initial testing indicates only a single lock that is used across goroutines. The new sync.CrossGoroutineMutex relaxes the requirement (but will not provide lock order checking). Due to the additional overhead, enforcement is only enabled with the "checklocks" build tag. Build with this tag using: bazel build --define=gotags=checklocks ... From my spot-checking, this has no changed inlining properties when disabled. Updates #4804 PiperOrigin-RevId: 343370200
Diffstat (limited to 'pkg/sync/BUILD')
-rw-r--r--pkg/sync/BUILD5
1 files changed, 5 insertions, 0 deletions
diff --git a/pkg/sync/BUILD b/pkg/sync/BUILD
index 68535c3b1..410e9a3ca 100644
--- a/pkg/sync/BUILD
+++ b/pkg/sync/BUILD
@@ -31,6 +31,8 @@ go_library(
name = "sync",
srcs = [
"aliases.go",
+ "checklocks_off_unsafe.go",
+ "checklocks_on_unsafe.go",
"memmove_unsafe.go",
"mutex_unsafe.go",
"nocopy.go",
@@ -43,6 +45,9 @@ go_library(
],
marshal = False,
stateify = False,
+ deps = [
+ "//pkg/goid",
+ ],
)
go_test(