Commit d8071ffd authored by Pavel Emelyanov's avatar Pavel Emelyanov

stats: Fix restore pages stats

We errorneously report nr_compared as total number of restored pages.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent b745ae83
...@@ -324,6 +324,7 @@ static int restore_priv_vma_content(pid_t pid) ...@@ -324,6 +324,7 @@ static int restore_priv_vma_content(pid_t pid)
unsigned int nr_restored = 0; unsigned int nr_restored = 0;
unsigned int nr_shared = 0; unsigned int nr_shared = 0;
unsigned int nr_droped = 0; unsigned int nr_droped = 0;
unsigned int nr_compared = 0;
unsigned long va; unsigned long va;
struct page_read pr; struct page_read pr;
...@@ -386,6 +387,8 @@ static int restore_priv_vma_content(pid_t pid) ...@@ -386,6 +387,8 @@ static int restore_priv_vma_content(pid_t pid)
goto err_read; goto err_read;
va += PAGE_SIZE; va += PAGE_SIZE;
nr_compared++;
if (memcmp(p, buf, PAGE_SIZE) == 0) { if (memcmp(p, buf, PAGE_SIZE) == 0) {
nr_shared++; /* the page is cowed */ nr_shared++; /* the page is cowed */
continue; continue;
...@@ -438,8 +441,9 @@ err_read: ...@@ -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_SKIPPED_COW, nr_shared);
cnt_add(CNT_PAGES_RESTORED, nr_restored);
pr_info("nr_restored_pages: %d\n", nr_restored); pr_info("nr_restored_pages: %d\n", nr_restored);
pr_info("nr_shared_pages: %d\n", nr_shared); pr_info("nr_shared_pages: %d\n", nr_shared);
......
...@@ -32,6 +32,7 @@ enum { ...@@ -32,6 +32,7 @@ enum {
enum { enum {
CNT_PAGES_COMPARED, CNT_PAGES_COMPARED,
CNT_PAGES_SKIPPED_COW, CNT_PAGES_SKIPPED_COW,
CNT_PAGES_RESTORED,
RESTORE_CNT_NR_STATS, RESTORE_CNT_NR_STATS,
}; };
......
...@@ -18,6 +18,8 @@ message restore_stats_entry { ...@@ -18,6 +18,8 @@ message restore_stats_entry {
required uint32 forking_time = 3; required uint32 forking_time = 3;
required uint32 restore_time = 4; required uint32 restore_time = 4;
optional uint64 pages_restored = 5;
} }
message stats_entry { message stats_entry {
......
...@@ -128,6 +128,8 @@ void write_stats(int what) ...@@ -128,6 +128,8 @@ void write_stats(int what)
rs_entry.pages_compared = atomic_read(&rstats->counts[CNT_PAGES_COMPARED]); 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.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_FORK, &rs_entry.forking_time);
encode_time(TIME_RESTORE, &rs_entry.restore_time); encode_time(TIME_RESTORE, &rs_entry.restore_time);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment