From d8071ffd1aa456200353cd2251fbd9c24cc03b6a Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Tue, 4 Feb 2014 14:03:10 +0400 Subject: [PATCH] stats: Fix restore pages stats We errorneously report nr_compared as total number of restored pages. Signed-off-by: Pavel Emelyanov --- cr-restore.c | 6 +++++- include/stats.h | 1 + protobuf/stats.proto | 2 ++ stats.c | 2 ++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/cr-restore.c b/cr-restore.c index 073ba495d..0336aa751 100644 --- a/cr-restore.c +++ b/cr-restore.c @@ -324,6 +324,7 @@ static int restore_priv_vma_content(pid_t pid) unsigned int nr_restored = 0; unsigned int nr_shared = 0; unsigned int nr_droped = 0; + unsigned int nr_compared = 0; unsigned long va; struct page_read pr; @@ -386,6 +387,8 @@ static int restore_priv_vma_content(pid_t pid) goto err_read; va += PAGE_SIZE; + nr_compared++; + if (memcmp(p, buf, PAGE_SIZE) == 0) { nr_shared++; /* the page is cowed */ continue; @@ -438,8 +441,9 @@ err_read: } } - cnt_add(CNT_PAGES_COMPARED, nr_restored + nr_shared); + cnt_add(CNT_PAGES_COMPARED, nr_compared); cnt_add(CNT_PAGES_SKIPPED_COW, nr_shared); + cnt_add(CNT_PAGES_RESTORED, nr_restored); pr_info("nr_restored_pages: %d\n", nr_restored); pr_info("nr_shared_pages: %d\n", nr_shared); diff --git a/include/stats.h b/include/stats.h index ce33e885b..e417636e6 100644 --- a/include/stats.h +++ b/include/stats.h @@ -32,6 +32,7 @@ enum { enum { CNT_PAGES_COMPARED, CNT_PAGES_SKIPPED_COW, + CNT_PAGES_RESTORED, RESTORE_CNT_NR_STATS, }; diff --git a/protobuf/stats.proto b/protobuf/stats.proto index 38301a10f..775d25949 100644 --- a/protobuf/stats.proto +++ b/protobuf/stats.proto @@ -18,6 +18,8 @@ message restore_stats_entry { required uint32 forking_time = 3; required uint32 restore_time = 4; + + optional uint64 pages_restored = 5; } message stats_entry { diff --git a/stats.c b/stats.c index 6cbb54f71..01712150f 100644 --- a/stats.c +++ b/stats.c @@ -128,6 +128,8 @@ void write_stats(int what) rs_entry.pages_compared = atomic_read(&rstats->counts[CNT_PAGES_COMPARED]); rs_entry.pages_skipped_cow = atomic_read(&rstats->counts[CNT_PAGES_SKIPPED_COW]); + rs_entry.has_pages_restored = true; + rs_entry.pages_restored = atomic_read(&rstats->counts[CNT_PAGES_RESTORED]); encode_time(TIME_FORK, &rs_entry.forking_time); encode_time(TIME_RESTORE, &rs_entry.restore_time);