1. seandroid
  2. Untitled project
  3. system/extras

Commits

Colin Cross  committed 931563e

libpagemap: add pm_process_usage_flags

Add pm_process_usage flags to get memory usage by a process, only
counting pages with specified flags set.

Change-Id: I900b673ddbb5ae92312773a8670dd59769617268

  • Participants
  • Parent commits 9a209c3
  • Branches master

Comments (0)

Files changed (2)

File libpagemap/include/pagemap/pagemap.h

View file
  • Ignore whitespace
 /* Get the total memory usage of a process and store in *usage_out. */
 int pm_process_usage(pm_process_t *proc, pm_memusage_t *usage_out);
 
+/* Get the total memory usage of a process and store in *usage_out, only
+ * counting pages with specified flags. */
+int pm_process_usage_flags(pm_process_t *proc, pm_memusage_t *usage_out,
+                        uint64_t flags_mask, uint64_t required_flags);
+
 /* Get the working set of a process (if ws_out != NULL), and reset it
  * (if reset != 0). */
 int pm_process_workingset(pm_process_t *proc, pm_memusage_t *ws_out, int reset);

File libpagemap/pm_process.c

View file
  • Ignore whitespace
     return 0;
 }
 
-int pm_process_usage(pm_process_t *proc, pm_memusage_t *usage_out) {
+int pm_process_usage_flags(pm_process_t *proc, pm_memusage_t *usage_out,
+                        uint64_t flags_mask, uint64_t required_flags)
+{
     pm_memusage_t usage, map_usage;
     int error;
     int i;
     pm_memusage_zero(&usage);
 
     for (i = 0; i < proc->num_maps; i++) {
-        error = pm_map_usage(proc->maps[i], &map_usage);
+        error = pm_map_usage_flags(proc->maps[i], &map_usage, flags_mask,
+                                   required_flags);
         if (error) return error;
 
         pm_memusage_add(&usage, &map_usage);
     memcpy(usage_out, &usage, sizeof(pm_memusage_t));
 
     return 0;
+
+}
+
+int pm_process_usage(pm_process_t *proc, pm_memusage_t *usage_out) {
+    return pm_process_usage_flags(proc, usage_out, 0, 0);
 }
 
 int pm_process_pagemap_range(pm_process_t *proc,