MCPcopy
hub / github.com/google/gvisor / incRefLocked

Method incRefLocked

pkg/sentry/pgalloc/pgalloc.go:1182–1198  ·  view source on GitHub ↗

Preconditions: f.mu must be locked.

(fr memmap.FileRange)

Source from the content-addressed store, hash-verified

1180
1181// Preconditions: f.mu must be locked.
1182func (f *MemoryFile) incRefLocked(fr memmap.FileRange) {
1183 f.forEachChunk(fr, func(chunk *chunkInfo, chunkFR memmap.FileRange) bool {
1184 unfree := &f.unfreeSmall
1185 if chunk.huge {
1186 unfree = &f.unfreeHuge
1187 }
1188 unfree.MutateFullRange(chunkFR, func(ufseg unfreeIterator) bool {
1189 uf := ufseg.ValuePtr()
1190 if uf.refs <= 0 {
1191 panic(fmt.Sprintf("IncRef(%v) called with %d references on pages %v", fr, uf.refs, ufseg.Range()))
1192 }
1193 uf.refs++
1194 return true
1195 })
1196 return true
1197 })
1198}
1199
1200// DecRef implements memmap.File.DecRef.
1201func (f *MemoryFile) DecRef(fr memmap.FileRange) {

Callers 2

IncRefMethod · 0.95
mainMethod · 0.80

Calls 4

forEachChunkMethod · 0.95
MutateFullRangeMethod · 0.80
ValuePtrMethod · 0.80
RangeMethod · 0.45

Tested by

no test coverage detected