]> git.itanic.dy.fi Git - scan-pagemap/commitdiff
print_page_stats: Print unique pages
authorTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 15 Aug 2010 19:44:14 +0000 (22:44 +0300)
committerTimo Kokkonen <kaapeli@itanic.dy.fi>
Sun, 15 Aug 2010 19:44:14 +0000 (22:44 +0300)
Now that we don't scan interesting processes multiple times, we can
count the pages which have refcount == 1 as unique pages and show that
number to the user.

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

index 18e95c49fba977f26928d20f13b155be082abd7c..bb0679f3a1c1e27c7fd650602372dbc8dafad355 100644 (file)
--- a/analyze.c
+++ b/analyze.c
@@ -28,6 +28,7 @@ struct analyze_frames {
        struct bintree_ops ops;
        long int pages_present;
        long int pages_swapped;
+       long int pages_unique;
        int pid;
 };
 
@@ -56,6 +57,8 @@ get_stats:
                af->pages_present++;
        else if (pf->page_swapped)
                af->pages_swapped++;
+       if (pf->refcount == 1)
+               af->pages_unique++;
 }
 
 /*
@@ -72,6 +75,7 @@ void print_page_stats(struct pageframe *pf)
        count = bintree_walk(&pf->tree, &af.ops);
        printf("present pages: %ld, %lld %sB\n"
                "Swapped pages: %ld, %lld %sB\n"
+               "Unique pages: %ld, %lld %sB\n"
                "Total %ld physical pages, %lld %sB\n",
                af.pages_present,
                PAGE_TO_NICE(af.pages_present),
@@ -79,6 +83,9 @@ void print_page_stats(struct pageframe *pf)
                af.pages_swapped,
                PAGE_TO_NICE(af.pages_swapped),
                PAGE_TO_NICE_UNIT(af.pages_swapped),
+               af.pages_unique,
+               PAGE_TO_NICE(af.pages_unique),
+               PAGE_TO_NICE_UNIT(af.pages_unique),
                count,
                PAGE_TO_NICE(count),
                PAGE_TO_NICE_UNIT(count));