summaryrefslogtreecommitdiff
path: root/block
diff options
context:
space:
mode:
authorVladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>2018-03-09 19:52:12 +0300
committerEric Blake <eblake@redhat.com>2018-03-19 14:58:38 -0500
commit7e5c776d15b1fc0cda00c255ba035bdf81dbaa31 (patch)
treed73be2a0219f3c27bcb7a60cd235234613581509 /block
parentb741ae74170643de0fec3005c717e3a397c3e034 (diff)
downloadqemu-7e5c776d15b1fc0cda00c255ba035bdf81dbaa31.tar.gz
qapi: add block latency histogram interface
Set (and clear) histograms through new command block-latency-histogram-set and show new statistics in query-blockstats results. For now, the command is marked experimental with prefix 'x-', to gain experience with the interface without being stuck with design decisions. Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com> Message-Id: <20180309165212.97144-3-vsementsov@virtuozzo.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> [eblake: fix typos, mention x- prefix in commit message] Signed-off-by: Eric Blake <eblake@redhat.com>
Diffstat (limited to 'block')
-rw-r--r--block/qapi.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/block/qapi.c b/block/qapi.c
index f2e0aa2cbe..04c6fc69b9 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -394,6 +394,37 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info,
qapi_free_BlockInfo(info);
}
+static uint64List *uint64_list(uint64_t *list, int size)
+{
+ int i;
+ uint64List *out_list = NULL;
+ uint64List **pout_list = &out_list;
+
+ for (i = 0; i < size; i++) {
+ uint64List *entry = g_new(uint64List, 1);
+ entry->value = list[i];
+ *pout_list = entry;
+ pout_list = &entry->next;
+ }
+
+ *pout_list = NULL;
+
+ return out_list;
+}
+
+static void bdrv_latency_histogram_stats(BlockLatencyHistogram *hist,
+ bool *not_null,
+ BlockLatencyHistogramInfo **info)
+{
+ *not_null = hist->bins != NULL;
+ if (*not_null) {
+ *info = g_new0(BlockLatencyHistogramInfo, 1);
+
+ (*info)->boundaries = uint64_list(hist->boundaries, hist->nbins - 1);
+ (*info)->bins = uint64_list(hist->bins, hist->nbins);
+ }
+}
+
static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
{
BlockAcctStats *stats = blk_get_stats(blk);
@@ -459,6 +490,16 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk)
dev_stats->avg_wr_queue_depth =
block_acct_queue_depth(ts, BLOCK_ACCT_WRITE);
}
+
+ bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_READ],
+ &ds->has_x_rd_latency_histogram,
+ &ds->x_rd_latency_histogram);
+ bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_WRITE],
+ &ds->has_x_wr_latency_histogram,
+ &ds->x_wr_latency_histogram);
+ bdrv_latency_histogram_stats(&stats->latency_histogram[BLOCK_ACCT_FLUSH],
+ &ds->has_x_flush_latency_histogram,
+ &ds->x_flush_latency_histogram);
}
static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs,