Commit c65f0684 authored by Pavel Emelyanov's avatar Pavel Emelyanov

stats: Add timing stats for restore

This will only work if timiings are reported by a single
task. Collecting them from several tasks is to be done.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ebd826c9
...@@ -11,6 +11,10 @@ enum { ...@@ -11,6 +11,10 @@ enum {
DUMP_TIME_NR_STATS, DUMP_TIME_NR_STATS,
}; };
enum {
RESTORE_TIME_NS_STATS,
};
void timing_start(int t); void timing_start(int t);
void timing_stop(int t); void timing_stop(int t);
......
...@@ -16,6 +16,7 @@ struct dump_stats { ...@@ -16,6 +16,7 @@ struct dump_stats {
}; };
struct restore_stats { struct restore_stats {
struct timing timings[RESTORE_TIME_NS_STATS];
atomic_t counts[RESTORE_CNT_NR_STATS]; atomic_t counts[RESTORE_CNT_NR_STATS];
}; };
...@@ -52,18 +53,40 @@ static void timeval_accumulate(const struct timeval *from, const struct timeval ...@@ -52,18 +53,40 @@ static void timeval_accumulate(const struct timeval *from, const struct timeval
} }
} }
static struct timing *get_timing(int t)
{
if (dstats != NULL) {
BUG_ON(t >= DUMP_TIME_NR_STATS);
return &dstats->timings[t];
} else if (rstats != NULL) {
/*
* FIXME -- this does _NOT_ work when called
* from different tasks.
*/
BUG_ON(t >= RESTORE_TIME_NS_STATS);
return &rstats->timings[t];
}
BUG();
return NULL;
}
void timing_start(int t) void timing_start(int t)
{ {
BUG_ON(t >= DUMP_TIME_NR_STATS); struct timing *tm;
gettimeofday(&dstats->timings[t].start, NULL);
tm = get_timing(t);
gettimeofday(&tm->start, NULL);
} }
void timing_stop(int t) void timing_stop(int t)
{ {
struct timing *tm;
struct timeval now; struct timeval now;
tm = get_timing(t);
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
timeval_accumulate(&dstats->timings[t].start, &now, &dstats->timings[t].total); timeval_accumulate(&tm->start, &now, &tm->total);
} }
void show_stats(int fd) void show_stats(int fd)
......
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