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

Method cancelWasteLoad

pkg/sentry/pgalloc/save_restore.go:1924–1945  ·  view source on GitHub ↗

Preconditions: - All pages in fr must be becoming waste pages. - fr must be page-aligned.

(fr memmap.FileRange)

Source from the content-addressed store, hash-verified

1922// - All pages in fr must be becoming waste pages.
1923// - fr must be page-aligned.
1924func (amfl *asyncMemoryFileLoad) cancelWasteLoad(fr memmap.FileRange) {
1925 // Lockless fast path:
1926 if fr.End <= amfl.minUnloaded.Load() {
1927 return
1928 }
1929
1930 amfl.pf.mu.Lock()
1931 defer amfl.pf.mu.Unlock()
1932 amfl.unloaded.RemoveRangeWith(fr, func(ulseg aplUnloadedIterator) {
1933 ul := ulseg.ValuePtr()
1934 if ul.started {
1935 // This shouldn't be possible since page references are held while
1936 // reading (see MemoryFile.asyncPageLoadMain()).
1937 panic(fmt.Sprintf("pages %v becoming waste during inflight read from async loading", ulseg.Range()))
1938 }
1939 if n := len(ul.waiters); n != 0 {
1940 // This shouldn't be possible since the waiters should hold page
1941 // references.
1942 panic(fmt.Sprintf("pages %v becoming waste with %d async load waiters", ulseg.Range(), n))
1943 }
1944 })
1945}
1946
1947type aplUnloadedSetFunctions struct{}
1948

Callers 1

DecRefMethod · 0.80

Calls 6

RemoveRangeWithMethod · 0.80
ValuePtrMethod · 0.80
LoadMethod · 0.65
LockMethod · 0.65
UnlockMethod · 0.65
RangeMethod · 0.45

Tested by

no test coverage detected