diff options
author | Sandeep Patil <sspatil@google.com> | 2018-10-09 13:58:01 -0700 |
---|---|---|
committer | Sandeep Patil <sspatil@google.com> | 2018-10-23 15:37:36 -0700 |
commit | f0384e77821d48cbca2d57426f21ba054b77757b (patch) | |
tree | d8369840b4d0371488e760261161db65b5c5a219 /libpagemap | |
parent | 99d37b48bbfee9955a8b2f71ea59fe42cc1e2e49 (diff) | |
download | extras-f0384e77821d48cbca2d57426f21ba054b77757b.tar.gz |
libpagemap: pm_map: skip pages that are neither present nor swapped.
The pm_map_workingset() code needlessly iterates through all the pages
in the map regardless of whether they are actually present or not. Fix
that by skipping the page if its not swapped AND not present.
Bug: 111694435
Test: procmem -h -w 1
Change-Id: I8f16e8c516a5272ebeaa537c07b08ae9f41b73ca
Signed-off-by: Sandeep Patil <sspatil@google.com>
Diffstat (limited to 'libpagemap')
-rw-r--r-- | libpagemap/pm_map.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/libpagemap/pm_map.c b/libpagemap/pm_map.c index 158a4faa..3e23c41c 100644 --- a/libpagemap/pm_map.c +++ b/libpagemap/pm_map.c @@ -130,6 +130,10 @@ int pm_map_workingset(pm_map_t* map, pm_memusage_t* ws_out) { pm_memusage_zero(&ws); for (i = 0; i < len; i++) { + if (!PM_PAGEMAP_PRESENT(pagemap[i]) && !PM_PAGEMAP_SWAPPED(pagemap[i])) { + continue; + } + if (!pm_kernel_page_is_accessed(map->proc->ker, PM_PAGEMAP_PFN(pagemap[i]), NULL)) { continue; } |