From d1f84c821af2c20066c861cea8304a84a41c7813 Mon Sep 17 00:00:00 2001 From: Timo Kokkonen Date: Sun, 15 Aug 2010 22:44:14 +0300 Subject: [PATCH] print_page_stats: Print unique pages 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 --- analyze.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/analyze.c b/analyze.c index 18e95c4..bb0679f 100644 --- 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)); -- 2.45.0