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)
| 1079 | // - fr.Length() > 0. |
| 1080 | // - At least one reference must be held on all pages in fr. |
| 1081 | func (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 | |
| 1107 | func (f *MemoryFile) commitFile(fr memmap.FileRange) error { |
| 1108 | // "The default operation (i.e., mode is zero) of fallocate() allocates the |
nothing calls this directly
no test coverage detected