Update MM.usageAS when mremap copies or moves a mapping.

PiperOrigin-RevId: 224221509
Change-Id: I7aaea74629227d682786d3e435737364921249bf
This commit is contained in:
Jamie Liu
2018-12-05 14:27:23 -08:00
committed by Shentubot
parent fda4557e3d
commit 23438b3632
+4 -4
View File
@@ -463,6 +463,7 @@ func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr usermem.Addr, oldSi
vma.id.IncRef()
}
mm.vmas.Add(newAR, vma)
mm.usageAS += uint64(newAR.Length())
return newAR.Start, nil
}
@@ -479,14 +480,13 @@ func (mm *MemoryManager) MRemap(ctx context.Context, oldAddr usermem.Addr, oldSi
// oldAR, so calling RemoveMapping could cause us to miss an invalidation
// overlapping oldAR.
//
// Call vseg.Value() (rather than vseg.ValuePtr()) first to make a copy of
// the vma.
// Call vseg.Value() (rather than vseg.ValuePtr()) to make a copy of the
// vma.
vseg = mm.vmas.Isolate(vseg, oldAR)
vma := vseg.Value()
mm.vmas.Remove(vseg)
// Insert the new vma, transferring the reference on vma.id.
mm.vmas.Add(newAR, vma)
mm.usageAS = mm.usageAS - uint64(oldAR.Length()) + uint64(newAR.Length())
// Move pmas. This is technically optional for non-private pmas, which
// could just go through memmap.Mappable.Translate again, but it's required