MCPcopy Index your code
hub / github.com/google/gvisor / Decommit

Method Decommit

pkg/sentry/pgalloc/pgalloc.go:1081–1105  ·  view source on GitHub ↗

Decommit uncommits the given pages, causing them to become zeroed. Preconditions: - fr.Start and fr.End must be page-aligned. - fr.Length() > 0. - At least one reference must be held on all pages in fr.

(fr memmap.FileRange)

Source from the content-addressed store, hash-verified

1079// - fr.Length() > 0.
1080// - At least one reference must be held on all pages in fr.
1081func (f *MemoryFile) Decommit(fr memmap.FileRange) {
1082 if !fr.WellFormed() || fr.Length() == 0 || fr.Start%hostarch.PageSize != 0 || fr.End%hostarch.PageSize != 0 {
1083 panic(fmt.Sprintf("invalid range: %v", fr))
1084 }
1085
1086 f.decommitOrManuallyZero(fr)
1087
1088 f.mu.Lock()
1089 defer f.mu.Unlock()
1090 f.memAcct.MutateFullRange(fr, func(maseg memAcctIterator) bool {
1091 ma := maseg.ValuePtr()
1092 if ma.knownCommitted {
1093 ma.knownCommitted = false
1094 malen := maseg.Range().Length()
1095 f.knownCommittedBytes -= malen
1096 if !f.opts.DisableMemoryAccounting {
1097 usage.MemoryAccounting.Dec(malen, ma.kind, ma.memCgID)
1098 }
1099 }
1100 // Update commitSeq to invalidate any observations made by
1101 // concurrent calls to f.updateUsageLocked().
1102 ma.commitSeq = f.commitSeq
1103 return true
1104 })
1105}
1106
1107func (f *MemoryFile) commitFile(fr memmap.FileRange) error {
1108 // "The default operation (i.e., mode is zero) of fallocate() allocates the

Callers

nothing calls this directly

Calls 9

WellFormedMethod · 0.80
MutateFullRangeMethod · 0.80
ValuePtrMethod · 0.80
DecMethod · 0.80
LockMethod · 0.65
UnlockMethod · 0.65
LengthMethod · 0.45
RangeMethod · 0.45

Tested by

no test coverage detected