summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/mm/address_space.go
diff options
context:
space:
mode:
authorFabricio Voznika <fvoznika@google.com>2020-02-25 13:42:34 -0800
committergVisor bot <gvisor-bot@google.com>2020-02-25 13:44:18 -0800
commit72e3f3a3eef3a1dc02db0ff71f98a5d7fe89a6e3 (patch)
tree54d520df721a706fdffabda9e6c560b197cdee86 /pkg/sentry/mm/address_space.go
parent430992a67abe30dc6cb4e00822517c0aed388088 (diff)
Add option to skip stuck tasks waiting for address space
PiperOrigin-RevId: 297192390
Diffstat (limited to 'pkg/sentry/mm/address_space.go')
-rw-r--r--pkg/sentry/mm/address_space.go23
1 files changed, 14 insertions, 9 deletions
diff --git a/pkg/sentry/mm/address_space.go b/pkg/sentry/mm/address_space.go
index 94d39af60..0332fc71c 100644
--- a/pkg/sentry/mm/address_space.go
+++ b/pkg/sentry/mm/address_space.go
@@ -18,6 +18,7 @@ import (
"fmt"
"sync/atomic"
+ "gvisor.dev/gvisor/pkg/context"
"gvisor.dev/gvisor/pkg/sentry/platform"
"gvisor.dev/gvisor/pkg/usermem"
)
@@ -38,7 +39,7 @@ func (mm *MemoryManager) AddressSpace() platform.AddressSpace {
//
// When this MemoryManager is no longer needed by a task, it should call
// Deactivate to release the reference.
-func (mm *MemoryManager) Activate() error {
+func (mm *MemoryManager) Activate(ctx context.Context) error {
// Fast path: the MemoryManager already has an active
// platform.AddressSpace, and we just need to indicate that we need it too.
for {
@@ -91,16 +92,20 @@ func (mm *MemoryManager) Activate() error {
if as == nil {
// AddressSpace is unavailable, we must wait.
//
- // activeMu must not be held while waiting, as the user
- // of the address space we are waiting on may attempt
- // to take activeMu.
- //
- // Don't call UninterruptibleSleepStart to register the
- // wait to allow the watchdog stuck task to trigger in
- // case a process is starved waiting for the address
- // space.
+ // activeMu must not be held while waiting, as the user of the address
+ // space we are waiting on may attempt to take activeMu.
mm.activeMu.Unlock()
+
+ sleep := mm.p.CooperativelySchedulesAddressSpace() && mm.sleepForActivation
+ if sleep {
+ // Mark this task sleeping while waiting for the address space to
+ // prevent the watchdog from reporting it as a stuck task.
+ ctx.UninterruptibleSleepStart(false)
+ }
<-c
+ if sleep {
+ ctx.UninterruptibleSleepFinish(false)
+ }
continue
}