diff options
author | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-16 21:55:20 +0000 |
---|---|---|
committer | davemoore@chromium.org <davemoore@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-16 21:55:20 +0000 |
commit | 23deabb766b17dbce4cfa44b7dac8c858d0a3ad7 (patch) | |
tree | 70cdb2babd1e0b716ef45dd051758836f93ac162 /base/process | |
parent | 10bc54a0e229adf3700c9a7ae525e65472470bf4 (diff) | |
download | chromium_src-23deabb766b17dbce4cfa44b7dac8c858d0a3ad7.zip chromium_src-23deabb766b17dbce4cfa44b7dac8c858d0a3ad7.tar.gz chromium_src-23deabb766b17dbce4cfa44b7dac8c858d0a3ad7.tar.bz2 |
Record swap sizes on ChromeOS
BUG=260484
TEST=None
R=brettw@chromium.org, jam@chromium.org, jar@chromium.org
Review URL: https://codereview.chromium.org/19267012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211857 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process')
-rw-r--r-- | base/process/process_metrics.h | 14 | ||||
-rw-r--r-- | base/process/process_metrics_linux.cc | 40 |
2 files changed, 41 insertions, 13 deletions
diff --git a/base/process/process_metrics.h b/base/process/process_metrics.h index 3a6a30b..2db5d48 100644 --- a/base/process/process_metrics.h +++ b/base/process/process_metrics.h @@ -45,19 +45,29 @@ struct IoCounters { // other process. // // On Linux: -// priv: Pages mapped only by this process -// shared: PSS or 0 if the kernel doesn't support this +// priv: Pages mapped only by this process. +// shared: PSS or 0 if the kernel doesn't support this. // shareable: 0 + +// On ChromeOS: +// priv: Pages mapped only by this process. +// shared: PSS or 0 if the kernel doesn't support this. +// shareable: 0 +// swapped Pages swapped out to zram. // // On OS X: TODO(thakis): Revise. // priv: Memory. // shared: 0 // shareable: 0 +// struct WorkingSetKBytes { WorkingSetKBytes() : priv(0), shareable(0), shared(0) {} size_t priv; size_t shareable; size_t shared; +#if defined(OS_CHROMEOS) + size_t swapped; +#endif }; // Committed (resident + paged) memory usage broken down by diff --git a/base/process/process_metrics_linux.cc b/base/process/process_metrics_linux.cc index 21e5a5d..0171020 100644 --- a/base/process/process_metrics_linux.cc +++ b/base/process/process_metrics_linux.cc @@ -275,10 +275,15 @@ bool ProcessMetrics::GetWorkingSetKBytesTotmaps(WorkingSetKBytes *ws_usage) // Shared_Dirty: 4012 kB // Private_Clean: 4 kB // Private_Dirty: 1096 kB - // ... - const size_t kPssIndex = 4; - const size_t kPrivate_CleanIndex = 13; - const size_t kPrivate_DirtyIndex = 16; + // Referenced: XXX kB + // Anonymous: XXX kB + // AnonHugePages: XXX kB + // Swap: XXX kB + // Locked: XXX kB + const size_t kPssIndex = (1 * 3) + 1; + const size_t kPrivate_CleanIndex = (4 * 3) + 1; + const size_t kPrivate_DirtyIndex = (5 * 3) + 1; + const size_t kSwapIndex = (9 * 3) + 1; std::string totmaps_data; { @@ -293,19 +298,27 @@ bool ProcessMetrics::GetWorkingSetKBytesTotmaps(WorkingSetKBytes *ws_usage) SplitStringAlongWhitespace(totmaps_data, &totmaps_fields); DCHECK_EQ("Pss:", totmaps_fields[kPssIndex-1]); - DCHECK_EQ("Private_Clean:", totmaps_fields[kPrivate_CleanIndex-1]); - DCHECK_EQ("Private_Dirty:", totmaps_fields[kPrivate_DirtyIndex-1]); - - int pss, private_clean, private_dirty; + DCHECK_EQ("Private_Clean:", totmaps_fields[kPrivate_CleanIndex - 1]); + DCHECK_EQ("Private_Dirty:", totmaps_fields[kPrivate_DirtyIndex - 1]); + DCHECK_EQ("Swap:", totmaps_fields[kSwapIndex-1]); + + int pss = 0; + int private_clean = 0; + int private_dirty = 0; + int swap = 0; bool ret = true; ret &= StringToInt(totmaps_fields[kPssIndex], &pss); ret &= StringToInt(totmaps_fields[kPrivate_CleanIndex], &private_clean); ret &= StringToInt(totmaps_fields[kPrivate_DirtyIndex], &private_dirty); + ret &= StringToInt(totmaps_fields[kSwapIndex], &swap); - ws_usage->priv = private_clean + private_dirty; - ws_usage->shared = pss; + // On ChromeOS swap is to zram. We count this as private / shared, as + // increased swap decreases available RAM to user processes, which would + // otherwise create surprising results. + ws_usage->priv = private_clean + private_dirty + swap; + ws_usage->shared = pss + swap; ws_usage->shareable = 0; - + ws_usage->swapped = swap; return ret; } #endif @@ -349,6 +362,11 @@ bool ProcessMetrics::GetWorkingSetKBytesStatm(WorkingSetKBytes* ws_usage) // Sharable is not calculated, as it does not provide interesting data. ws_usage->shareable = 0; +#if defined(OS_CHROMEOS) + // Can't get swapped memory from statm. + ws_usage->swapped = 0; +#endif + return ret; } |