Commit 6ac48701 authored by Pavel Emelyanov's avatar Pavel Emelyanov

stats: Prepare for collecting restore stats

Restore stats are difficult -- we have to collect them from several
tasks and thus existing plain variables would not work. We'll need
shared memory with stats, so prepre for allocating one.

Other than this -- put call to write_stats() where appropriate for
restore.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 7f930250
...@@ -1593,6 +1593,9 @@ int cr_pre_dump_tasks(pid_t pid) ...@@ -1593,6 +1593,9 @@ int cr_pre_dump_tasks(pid_t pid)
LIST_HEAD(ctls); LIST_HEAD(ctls);
struct parasite_ctl *ctl, *n; struct parasite_ctl *ctl, *n;
if (init_stats(DUMP_STATS))
goto err;
if (kerndat_init()) if (kerndat_init())
goto err; goto err;
...@@ -1657,6 +1660,9 @@ int cr_dump_tasks(pid_t pid) ...@@ -1657,6 +1660,9 @@ int cr_dump_tasks(pid_t pid)
pr_info("Dumping processes (pid: %d)\n", pid); pr_info("Dumping processes (pid: %d)\n", pid);
pr_info("========================================\n"); pr_info("========================================\n");
if (init_stats(DUMP_STATS))
goto err;
if (kerndat_init()) if (kerndat_init())
goto err; goto err;
......
...@@ -60,6 +60,7 @@ ...@@ -60,6 +60,7 @@
#include "page-read.h" #include "page-read.h"
#include "sysctl.h" #include "sysctl.h"
#include "vdso.h" #include "vdso.h"
#include "stats.h"
#include "protobuf.h" #include "protobuf.h"
#include "protobuf/sa.pb-c.h" #include "protobuf/sa.pb-c.h"
...@@ -1360,6 +1361,8 @@ out: ...@@ -1360,6 +1361,8 @@ out:
pr_info("Restore finished successfully. Resuming tasks.\n"); pr_info("Restore finished successfully. Resuming tasks.\n");
futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE); futex_set_and_wake(&task_entries->start, CR_STATE_COMPLETE);
write_stats(RESTORE_STATS);
if (!opts.restore_detach) if (!opts.restore_detach)
wait(NULL); wait(NULL);
return 0; return 0;
...@@ -1386,6 +1389,9 @@ int cr_restore_tasks(void) ...@@ -1386,6 +1389,9 @@ int cr_restore_tasks(void)
if (check_img_inventory() < 0) if (check_img_inventory() < 0)
return -1; return -1;
if (init_stats(RESTORE_STATS))
return -1;
if (cpu_init() < 0) if (cpu_init() < 0)
return -1; return -1;
......
...@@ -25,6 +25,9 @@ enum { ...@@ -25,6 +25,9 @@ enum {
void cnt_add(int c, unsigned long val); void cnt_add(int c, unsigned long val);
#define DUMP_STATS 1 #define DUMP_STATS 1
#define RESTORE_STATS 2
int init_stats(int what);
void write_stats(int what); void write_stats(int what);
#endif #endif
...@@ -93,3 +93,11 @@ void write_stats(int what) ...@@ -93,3 +93,11 @@ void write_stats(int what)
close(fd); close(fd);
} }
} }
int init_stats(int what)
{
if (what == DUMP_STATS)
return 0;
return 0;
}
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