mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-03 07:43:54 -06:00
block: latency accounting
Account the total latency for read/write/flush requests. This allows management tools to average it based on a snapshot of the nr ops counters and allow checking for SLAs or provide statistics. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
This commit is contained in:
parent
a597e79ce1
commit
c488c7f649
4 changed files with 38 additions and 3 deletions
20
block.c
20
block.c
|
@ -1916,12 +1916,18 @@ static void bdrv_stats_iter(QObject *data, void *opaque)
|
|||
" rd_operations=%" PRId64
|
||||
" wr_operations=%" PRId64
|
||||
" flush_operations=%" PRId64
|
||||
" wr_total_time_ns=%" PRId64
|
||||
" rd_total_time_ns=%" PRId64
|
||||
" flush_total_time_ns=%" PRId64
|
||||
"\n",
|
||||
qdict_get_int(qdict, "rd_bytes"),
|
||||
qdict_get_int(qdict, "wr_bytes"),
|
||||
qdict_get_int(qdict, "rd_operations"),
|
||||
qdict_get_int(qdict, "wr_operations"),
|
||||
qdict_get_int(qdict, "flush_operations"));
|
||||
qdict_get_int(qdict, "flush_operations"),
|
||||
qdict_get_int(qdict, "wr_total_time_ns"),
|
||||
qdict_get_int(qdict, "rd_total_time_ns"),
|
||||
qdict_get_int(qdict, "flush_total_time_ns"));
|
||||
}
|
||||
|
||||
void bdrv_stats_print(Monitor *mon, const QObject *data)
|
||||
|
@ -1940,7 +1946,10 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
|
|||
"'rd_operations': %" PRId64 ","
|
||||
"'wr_operations': %" PRId64 ","
|
||||
"'wr_highest_offset': %" PRId64 ","
|
||||
"'flush_operations': %" PRId64
|
||||
"'flush_operations': %" PRId64 ","
|
||||
"'wr_total_time_ns': %" PRId64 ","
|
||||
"'rd_total_time_ns': %" PRId64 ","
|
||||
"'flush_total_time_ns': %" PRId64
|
||||
"} }",
|
||||
bs->nr_bytes[BDRV_ACCT_READ],
|
||||
bs->nr_bytes[BDRV_ACCT_WRITE],
|
||||
|
@ -1948,7 +1957,10 @@ static QObject* bdrv_info_stats_bs(BlockDriverState *bs)
|
|||
bs->nr_ops[BDRV_ACCT_WRITE],
|
||||
bs->wr_highest_sector *
|
||||
(uint64_t)BDRV_SECTOR_SIZE,
|
||||
bs->nr_ops[BDRV_ACCT_FLUSH]);
|
||||
bs->nr_ops[BDRV_ACCT_FLUSH],
|
||||
bs->total_time_ns[BDRV_ACCT_WRITE],
|
||||
bs->total_time_ns[BDRV_ACCT_READ],
|
||||
bs->total_time_ns[BDRV_ACCT_FLUSH]);
|
||||
dict = qobject_to_qdict(res);
|
||||
|
||||
if (*bs->device_name) {
|
||||
|
@ -3160,6 +3172,7 @@ bdrv_acct_start(BlockDriverState *bs, BlockAcctCookie *cookie, int64_t bytes,
|
|||
assert(type < BDRV_MAX_IOTYPE);
|
||||
|
||||
cookie->bytes = bytes;
|
||||
cookie->start_time_ns = get_clock();
|
||||
cookie->type = type;
|
||||
}
|
||||
|
||||
|
@ -3170,6 +3183,7 @@ bdrv_acct_done(BlockDriverState *bs, BlockAcctCookie *cookie)
|
|||
|
||||
bs->nr_bytes[cookie->type] += cookie->bytes;
|
||||
bs->nr_ops[cookie->type]++;
|
||||
bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
|
||||
}
|
||||
|
||||
int bdrv_img_create(const char *filename, const char *fmt,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue