Lockdep: Print more info in the "unbalanced unlock" case.

This CL does the following:

- Add the ability for nested locks to have names.
- Give names to all current uses of nested locks in the codebase.
- Truncate `lockdep` debug stack traces to avoid the clutter from the
  `lockdep` code itself
- Simplify `lockdep` to not longer require `classMap`.

PiperOrigin-RevId: 491486620
This commit is contained in:
Etienne Perot
2022-11-28 17:53:09 -08:00
committed by gVisor bot
parent ae731e0394
commit 445fa6f40c
27 changed files with 327 additions and 213 deletions
+3 -5
View File
@@ -1,5 +1,6 @@
load("//tools:defs.bzl", "go_library")
load("//tools/go_generics:defs.bzl", "go_template_instance")
load("//pkg/sync/locking:locking.bzl", "declare_mutex")
package(licenses = ["notice"])
@@ -42,15 +43,12 @@ go_template_instance(
},
)
go_template_instance(
declare_mutex(
name = "user_namespace_mutex",
out = "user_namespace_mutex.go",
nested_lock_names = ["ns"],
package = "auth",
prefix = "userNamespace",
substrs = {
"genericMark": "userNamespace",
},
template = "//pkg/sync/locking:generic_mutex",
)
go_library(
+2 -2
View File
@@ -69,8 +69,8 @@ func (ns *UserNamespace) mapID(m *idMapSet, id uint32) uint32 {
//
// Preconditions: end >= start.
func (ns *UserNamespace) allIDsMapped(m *idMapSet, start, end uint32) bool {
ns.mu.NestedLock()
defer ns.mu.NestedUnlock()
ns.mu.NestedLock(userNamespaceLockNs)
defer ns.mu.NestedUnlock(userNamespaceLockNs)
return m.SpanRange(idMapRange{start, end}) == end-start
}