Remove error return from AddressSpace.Release()

PiperOrigin-RevId: 196291289
Change-Id: Ie3487be029850b0b410b82416750853a6c4a2b00
This commit is contained in:
Michael Pratt
2018-05-11 12:24:15 -07:00
committed by Shentubot
parent 12c161f278
commit 8deabbaae1
5 changed files with 10 additions and 19 deletions
+1 -3
View File
@@ -39,9 +39,7 @@ func (t *Task) Activate() {
// Deactivate relinquishes the task's active address space.
func (t *Task) Deactivate() {
if mm := t.MemoryManager(); mm != nil {
if err := mm.Deactivate(); err != nil {
panic("unable to deactivate mm: " + err.Error())
}
mm.Deactivate()
}
}
+6 -11
View File
@@ -114,12 +114,12 @@ func (mm *MemoryManager) Activate() error {
}
}
// Deactivate releases a release to the MemoryManager.
func (mm *MemoryManager) Deactivate() error {
// Deactivate releases a reference to the MemoryManager.
func (mm *MemoryManager) Deactivate() {
// Fast path: this is not the last goroutine to deactivate the
// MemoryManager.
if atomicbitops.DecUnlessOneInt32(&mm.active) {
return nil
return
}
mm.activeMu.Lock()
@@ -128,26 +128,21 @@ func (mm *MemoryManager) Deactivate() error {
// Still active?
if atomic.AddInt32(&mm.active, -1) > 0 {
mm.activeMu.Unlock()
return nil
return
}
// Can we hold on to the address space?
if !mm.p.CooperativelySchedulesAddressSpace() {
mm.activeMu.Unlock()
return nil
return
}
// Release the address space.
if err := mm.as.Release(); err != nil {
atomic.StoreInt32(&mm.active, 1)
mm.activeMu.Unlock()
return err
}
mm.as.Release()
// Lost it.
mm.as = nil
mm.activeMu.Unlock()
return nil
}
// mapASLocked maps addresses in ar into mm.as. If precommit is true, mappings
+1 -2
View File
@@ -200,8 +200,7 @@ func (as *addressSpace) Unmap(addr usermem.Addr, length uint64) {
}
// Release releases the page tables.
func (as *addressSpace) Release() error {
func (as *addressSpace) Release() {
as.Unmap(0, ^uint64(0))
as.pageTables.Release()
return nil
}
+1 -1
View File
@@ -205,7 +205,7 @@ type AddressSpace interface {
// Release releases this address space. After releasing, a new AddressSpace
// must be acquired via platform.NewAddressSpace().
Release() error
Release()
// AddressSpaceIO methods are supported iff the associated platform's
// Platform.SupportsAddressSpaceIO() == true. AddressSpaces for which this
+1 -2
View File
@@ -242,14 +242,13 @@ func (s *subprocess) unmap() {
// Therefore we simply unmap everything in the subprocess and return it to the
// globalPool. This has the added benefit of reducing creation time for new
// subprocesses.
func (s *subprocess) Release() error {
func (s *subprocess) Release() {
go func() { // S/R-SAFE: Platform.
s.unmap()
globalPool.mu.Lock()
globalPool.available = append(globalPool.available, s)
globalPool.mu.Unlock()
}()
return nil
}
// newThread creates a new traced thread.