diff options
author | gVisor bot <gvisor-bot@google.com> | 2020-02-25 21:48:45 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-02-25 21:48:45 +0000 |
commit | 252dac4e03e749ead75db6ba10b1d79603d9d1a7 (patch) | |
tree | a142c411962110bffd4ec55c0def6db6087e4287 /pkg/sentry/mm/address_space.go | |
parent | d2b2e5e17a8664653211e763204cc01b78b5c7a9 (diff) | |
parent | 72e3f3a3eef3a1dc02db0ff71f98a5d7fe89a6e3 (diff) |
Merge release-20200219.0-40-g72e3f3a (automated)
Diffstat (limited to 'pkg/sentry/mm/address_space.go')
-rw-r--r-- | pkg/sentry/mm/address_space.go | 23 |
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 } |