]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
Analyzer: Add per pid analyzer
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 4 Jul 2010 20:22:14 +0000 (23:22 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 4 Jul 2010 20:23:31 +0000 (23:23 +0300)
This will print statistics about how much data is being shared between
pids.

Signed-off-by: Timo Kokkonen <kaapeli@itanic.dy.fi>
analyze.c
analyze.h

index 916704721be98f164bf58f6f3c46b2d0dad4a671..4cb42e7c88ed08cc5560d32d85bac7476034264f 100644 (file)
--- a/analyze.c
+++ b/analyze.c
@@ -77,3 +77,30 @@ void print_page_stats(struct pageframe *pf)
                PAGE_TO_NICE(count),
                PAGE_TO_NICE_UNIT(count));
 }
+
+void print_pid_stats(struct pageframe *pf, struct process *process_list)
+{
+       struct process *ps;
+       struct maps *map;
+       long int swapped, present;
+
+       printf("   in ram   swapped    pid name\n");
+
+       list_for_each_entry(ps, &process_list->list, list) {
+               swapped = present = 0;
+
+               if (ps->maps)
+                       list_for_each_entry(map, &ps->maps->list, list) {
+                               present += map->pages_present;
+                               swapped += map->pages_swapped;
+                       }
+
+               if ((swapped + present) == 0)
+                       continue;
+
+               printf("% 6lld %sB % 6lld %sB % 5d %s",
+                       PAGE_TO_NICE(present), PAGE_TO_NICE_UNIT(present),
+                       PAGE_TO_NICE(swapped), PAGE_TO_NICE_UNIT(swapped),
+                       ps->pid, ps->name);
+       }
+}
index e768fbd091cca65d85a04c67f908b032fde13003..03a300b8d944c2936dd8dd1ccd9e08c2e28c4f27 100644 (file)
--- a/analyze.h
+++ b/analyze.h
@@ -4,5 +4,6 @@
 #include "pagemap.h"
 
 void print_page_stats(struct pageframe *pf);
+void print_pid_stats(struct pageframe *pf, struct process *process_list);
 
 #endif