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

Method forEachChunk

pkg/sentry/pgalloc/pgalloc.go:246–258  ·  view source on GitHub ↗

forEachChunk invokes fn on a sequence of chunks that collectively span all bytes in fr. In each call, chunkFR is the subset of fr that falls within chunk. If any call to f returns false, forEachChunk stops iteration and returns.

(fr memmap.FileRange, fn func(chunk *chunkInfo, chunkFR memmap.FileRange) bool)

Source from the content-addressed store, hash-verified

244// chunk. If any call to f returns false, forEachChunk stops iteration and
245// returns.
246func (f *MemoryFile) forEachChunk(fr memmap.FileRange, fn func(chunk *chunkInfo, chunkFR memmap.FileRange) bool) {
247 chunks := f.chunksLoad()
248 chunkStart := fr.Start &^ chunkMask
249 i := int(fr.Start / chunkSize)
250 for chunkStart < fr.End {
251 chunkEnd := chunkStart + chunkSize
252 if !fn(&chunks[i], fr.Intersect(memmap.FileRange{chunkStart, chunkEnd})) {
253 return
254 }
255 chunkStart = chunkEnd
256 i++
257 }
258}
259
260// unwasteInfo is the value type of MemoryFile.unwasteSmall/Huge.
261//

Callers 9

TestFindAllocatable64KFunction · 0.95
SaveToMethod · 0.95
TestFindAllocatableFunction · 0.95
HasUniqueRefMethod · 0.95
incRefLockedMethod · 0.95
DecRefMethod · 0.95
forEachMappingSliceMethod · 0.95
updateUsageLockedMethod · 0.95

Calls 2

chunksLoadMethod · 0.95
IntersectMethod · 0.45

Tested by 2

TestFindAllocatable64KFunction · 0.76
TestFindAllocatableFunction · 0.76