Commit 9bb54501 authored by Pavel Emelyanov's avatar Pavel Emelyanov

stats: Introduce counters for restore

These are atomic_add-s on shmalloc-ed stats.
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ab95e97f
...@@ -22,6 +22,10 @@ enum { ...@@ -22,6 +22,10 @@ enum {
DUMP_CNT_NR_STATS, DUMP_CNT_NR_STATS,
}; };
enum {
RESTORE_CNT_NR_STATS = 1,
};
void cnt_add(int c, unsigned long val); void cnt_add(int c, unsigned long val);
#define DUMP_STATS 1 #define DUMP_STATS 1
......
...@@ -15,12 +15,23 @@ struct dump_stats { ...@@ -15,12 +15,23 @@ struct dump_stats {
unsigned long counts[DUMP_CNT_NR_STATS]; unsigned long counts[DUMP_CNT_NR_STATS];
}; };
struct restore_stats {
atomic_t counts[RESTORE_CNT_NR_STATS];
};
struct dump_stats *dstats; struct dump_stats *dstats;
struct restore_stats *rstats;
void cnt_add(int c, unsigned long val) void cnt_add(int c, unsigned long val)
{ {
BUG_ON(c >= DUMP_CNT_NR_STATS); if (dstats != NULL) {
dstats->counts[c] += val; BUG_ON(c >= DUMP_CNT_NR_STATS);
dstats->counts[c] += val;
} else if (rstats != NULL) {
BUG_ON(c >= RESTORE_CNT_NR_STATS);
atomic_add(&rstats->counts[c], val);
} else
BUG();
} }
static void timeval_accumulate(const struct timeval *from, const struct timeval *to, static void timeval_accumulate(const struct timeval *from, const struct timeval *to,
...@@ -104,5 +115,6 @@ int init_stats(int what) ...@@ -104,5 +115,6 @@ int init_stats(int what)
return dstats ? 0 : -1; return dstats ? 0 : -1;
} }
return 0; rstats = shmalloc(sizeof(struct restore_stats));
return rstats ? 0 : -1;
} }
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