summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fsimpl/proc
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2020-05-06 17:35:47 +0000
committergVisor bot <gvisor-bot@google.com>2020-05-06 17:35:47 +0000
commit9c0db04fe746df6260e9da0a0cd60a91f6c6887d (patch)
treee71152a5926e32f151e641f2fd4d71504bef7d8f /pkg/sentry/fsimpl/proc
parent568ef4b075849f04e329e964918dbbcaeb675602 (diff)
parent591ff0e424e3b30eb143bce06618cb8656784b90 (diff)
Merge release-20200422.0-34-g591ff0e (automated)
Diffstat (limited to 'pkg/sentry/fsimpl/proc')
-rwxr-xr-xpkg/sentry/fsimpl/proc/tasks_files.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/pkg/sentry/fsimpl/proc/tasks_files.go b/pkg/sentry/fsimpl/proc/tasks_files.go
index 92007df81..e5f13b69e 100755
--- a/pkg/sentry/fsimpl/proc/tasks_files.go
+++ b/pkg/sentry/fsimpl/proc/tasks_files.go
@@ -272,12 +272,16 @@ func (*meminfoData) Generate(ctx context.Context, buf *bytes.Buffer) error {
inactiveFile := file - activeFile
fmt.Fprintf(buf, "MemTotal: %8d kB\n", totalSize/1024)
- memFree := (totalSize - totalUsage) / 1024
+ memFree := totalSize - totalUsage
+ if memFree > totalSize {
+ // Underflow.
+ memFree = 0
+ }
// We use MemFree as MemAvailable because we don't swap.
// TODO(rahat): When reclaim is implemented the value of MemAvailable
// should change.
- fmt.Fprintf(buf, "MemFree: %8d kB\n", memFree)
- fmt.Fprintf(buf, "MemAvailable: %8d kB\n", memFree)
+ fmt.Fprintf(buf, "MemFree: %8d kB\n", memFree/1024)
+ fmt.Fprintf(buf, "MemAvailable: %8d kB\n", memFree/1024)
fmt.Fprintf(buf, "Buffers: 0 kB\n") // memory usage by block devices
fmt.Fprintf(buf, "Cached: %8d kB\n", (file+snapshot.Tmpfs)/1024)
// Emulate a system with no swap, which disables inactivation of anon pages.