stats: Fix restore pages stats

We errorneously report nr_compared as total number of restored pages.

Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
Pavel Emelyanov 2014-02-04 14:03:10 +04:00
parent b745ae83b3
commit d8071ffd1a
4 changed files with 10 additions and 1 deletions

View file

@ -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);

View file

@ -32,6 +32,7 @@ enum {
enum {
CNT_PAGES_COMPARED,
CNT_PAGES_SKIPPED_COW,
CNT_PAGES_RESTORED,
RESTORE_CNT_NR_STATS,
};

View file

@ -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 {

View file

@ -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);