diff options
author | chris.zn <chris.zn@alibaba-inc.com> | 2019-05-29 16:48:19 -0700 |
---|---|---|
committer | Shentubot <shentubot@google.com> | 2019-05-30 12:07:40 -0700 |
commit | b18df9bed6af3ff9b526c9ebdcde33dffeac161e (patch) | |
tree | e5b3b56d1edc92f3d9853245f7161393ead4428b /pkg/sentry/mm/vma.go | |
parent | 035a8fa38ed21da2e06db22d3dfd6122610fb856 (diff) |
Add VmData field to /proc/{pid}/status
VmData is the size of private data segments.
It has the same meaning as in Linux.
Change-Id: Iebf1ae85940a810524a6cde9c2e767d4233ddb2a
PiperOrigin-RevId: 250593739
Diffstat (limited to 'pkg/sentry/mm/vma.go')
-rw-r--r-- | pkg/sentry/mm/vma.go | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/pkg/sentry/mm/vma.go b/pkg/sentry/mm/vma.go index ad901344b..02203f79f 100644 --- a/pkg/sentry/mm/vma.go +++ b/pkg/sentry/mm/vma.go @@ -98,7 +98,7 @@ func (mm *MemoryManager) createVMALocked(ctx context.Context, opts memmap.MMapOp } // Finally insert the vma. - vseg := mm.vmas.Insert(vgap, ar, vma{ + v := vma{ mappable: opts.Mappable, off: opts.Offset, realPerms: opts.Perms, @@ -109,8 +109,13 @@ func (mm *MemoryManager) createVMALocked(ctx context.Context, opts memmap.MMapOp mlockMode: opts.MLockMode, id: opts.MappingIdentity, hint: opts.Hint, - }) + } + + vseg := mm.vmas.Insert(vgap, ar, v) mm.usageAS += opts.Length + if v.isPrivateDataLocked() { + mm.dataAS += opts.Length + } if opts.MLockMode != memmap.MLockNone { mm.lockedAS += opts.Length } @@ -374,6 +379,9 @@ func (mm *MemoryManager) removeVMAsLocked(ctx context.Context, ar usermem.AddrRa vma.id.DecRef() } mm.usageAS -= uint64(vmaAR.Length()) + if vma.isPrivateDataLocked() { + mm.dataAS -= uint64(vmaAR.Length()) + } if vma.mlockMode != memmap.MLockNone { mm.lockedAS -= uint64(vmaAR.Length()) } @@ -396,6 +404,13 @@ func (vma *vma) canWriteMappableLocked() bool { return !vma.private && vma.maxPerms.Write } +// isPrivateDataLocked identify the data segments - private, writable, not stack +// +// Preconditions: mm.mappingMu must be locked. +func (vma *vma) isPrivateDataLocked() bool { + return vma.realPerms.Write && vma.private && !vma.growsDown +} + // vmaSetFunctions implements segment.Functions for vmaSet. type vmaSetFunctions struct{} |