mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Update MM.usageAS when mremap copies or moves a mapping.
PiperOrigin-RevId: 224221509 Change-Id: I7aaea74629227d682786d3e435737364921249bf
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user