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

Function StartAsyncPagesFileLoad

pkg/sentry/pgalloc/save_restore.go:1321–1353  ·  view source on GitHub ↗

StartAsyncPagesFileLoad constructs asynchronous loading state for the pages file ar. It takes ownership of ar, even if it returns a non-nil error.

(ar stateio.AsyncReader, doneCallback func(error), timeline *timing.Timeline)

Source from the content-addressed store, hash-verified

1319// StartAsyncPagesFileLoad constructs asynchronous loading state for the pages
1320// file ar. It takes ownership of ar, even if it returns a non-nil error.
1321func StartAsyncPagesFileLoad(ar stateio.AsyncReader, doneCallback func(error), timeline *timing.Timeline) (*AsyncPagesFileLoad, error) {
1322 maxReadBytes := hostarch.PageRoundDown(ar.MaxReadBytes())
1323 if maxReadBytes <= 0 {
1324 ar.Close()
1325 return nil, fmt.Errorf("stateio.AsyncReader.MaxReadBytes() (%d) must be at least one page)", ar.MaxReadBytes())
1326 }
1327 // Cap maxParallel due to the uint32 range of bitmap.Bitmap.
1328 maxParallel := min(ar.MaxParallel(), 1<<30)
1329 apfl := &AsyncPagesFileLoad{
1330 timeStartWaiters: math.MaxInt64,
1331 timeline: timeline.Fork("async page loading"),
1332 doneCallback: doneCallback,
1333 ar: ar,
1334 maxReadBytes: maxReadBytes,
1335 qavail: maxParallel,
1336 opsBusy: bitmap.New(uint32(maxParallel)),
1337 ops: make([]aplOp, maxParallel),
1338 }
1339 // Mark ops in opsBusy that don't actually exist as permanently busy.
1340 for i, n := maxParallel, apfl.opsBusy.Size(); i < n; i++ {
1341 apfl.opsBusy.Add(uint32(i))
1342 }
1343 // Pre-allocate slices in ops.
1344 maxRanges := ar.MaxRanges()
1345 for i := range apfl.ops {
1346 op := &apfl.ops[i]
1347 op.frs = make([]memmap.FileRange, 0, maxRanges)
1348 op.iovecs = make([]unix.Iovec, 0, maxRanges)
1349 }
1350 apfl.lfStatus.Init()
1351 go apfl.main()
1352 return apfl, nil
1353}
1354
1355// MemoryFilesDone must be called after calling LoadFrom() for all MemoryFiles
1356// loading from apfl. MemoryFilesDone may be called multiple times; subsequent

Callers 2

backgroundGoroutineMethod · 0.92
startFSRestoreFunction · 0.92

Calls 13

mainMethod · 0.95
PageRoundDownFunction · 0.92
NewFunction · 0.92
minFunction · 0.85
MaxReadBytesMethod · 0.65
CloseMethod · 0.65
ErrorfMethod · 0.65
MaxParallelMethod · 0.65
ForkMethod · 0.65
SizeMethod · 0.65
AddMethod · 0.65
MaxRangesMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…