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

Method TotalUsage

pkg/sentry/pgalloc/pgalloc.go:1753–1762  ·  view source on GitHub ↗

TotalUsage returns an aggregate usage for all memory statistics except Mapped (which is external to MemoryFile). This is generally much cheaper than UpdateUsage, but will not provide a fine-grained breakdown.

()

Source from the content-addressed store, hash-verified

1751// Mapped (which is external to MemoryFile). This is generally much cheaper
1752// than UpdateUsage, but will not provide a fine-grained breakdown.
1753func (f *MemoryFile) TotalUsage() (uint64, error) {
1754 // Stat the underlying file to discover the underlying usage. stat(2)
1755 // always reports the allocated block count in units of 512 bytes. This
1756 // includes pages in the page cache and swapped pages.
1757 var stat unix.Stat_t
1758 if err := unix.Fstat(int(f.file.Fd()), &stat); err != nil {
1759 return 0, err
1760 }
1761 return uint64(stat.Blocks * 512), nil
1762}
1763
1764// TotalSize returns the current size of the backing file in bytes, which is an
1765// upper bound on the amount of memory that can currently be allocated from the

Callers 4

UpdateUsageMethod · 0.95
CollectMethod · 0.80
SysinfoFunction · 0.80
emitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected