[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 12/42] block: add accounting for merged requests
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 12/42] block: add accounting for merged requests |
Date: |
Fri, 6 Feb 2015 17:40:19 +0100 |
From: Peter Lieven <address@hidden>
Signed-off-by: Peter Lieven <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Reviewed-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block.c | 2 ++
block/accounting.c | 7 +++++++
block/qapi.c | 2 ++
hmp.c | 6 +++++-
include/block/accounting.h | 3 +++
qapi/block-core.json | 9 ++++++++-
qmp-commands.hx | 22 ++++++++++++++++++----
7 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/block.c b/block.c
index ee7ff2c..8272ef9 100644
--- a/block.c
+++ b/block.c
@@ -4559,6 +4559,8 @@ static int multiwrite_merge(BlockDriverState *bs,
BlockRequest *reqs,
}
}
+ block_acct_merge_done(&bs->stats, BLOCK_ACCT_WRITE, num_reqs - outidx - 1);
+
return outidx + 1;
}
diff --git a/block/accounting.c b/block/accounting.c
index 18102f0..01d594f 100644
--- a/block/accounting.c
+++ b/block/accounting.c
@@ -54,3 +54,10 @@ void block_acct_highest_sector(BlockAcctStats *stats,
int64_t sector_num,
stats->wr_highest_sector = sector_num + nb_sectors - 1;
}
}
+
+void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type,
+ int num_requests)
+{
+ assert(type < BLOCK_MAX_IOTYPE);
+ stats->merged[type] += num_requests;
+}
diff --git a/block/qapi.c b/block/qapi.c
index 75c388e..d1a8917 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -335,6 +335,8 @@ static BlockStats *bdrv_query_stats(const BlockDriverState
*bs,
s->stats->wr_bytes = bs->stats.nr_bytes[BLOCK_ACCT_WRITE];
s->stats->rd_operations = bs->stats.nr_ops[BLOCK_ACCT_READ];
s->stats->wr_operations = bs->stats.nr_ops[BLOCK_ACCT_WRITE];
+ s->stats->rd_merged = bs->stats.merged[BLOCK_ACCT_READ];
+ s->stats->wr_merged = bs->stats.merged[BLOCK_ACCT_WRITE];
s->stats->wr_highest_offset =
bs->stats.wr_highest_sector * BDRV_SECTOR_SIZE;
s->stats->flush_operations = bs->stats.nr_ops[BLOCK_ACCT_FLUSH];
diff --git a/hmp.c b/hmp.c
index a42c5c0..b47f331 100644
--- a/hmp.c
+++ b/hmp.c
@@ -474,6 +474,8 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
" wr_total_time_ns=%" PRId64
" rd_total_time_ns=%" PRId64
" flush_total_time_ns=%" PRId64
+ " rd_merged=%" PRId64
+ " wr_merged=%" PRId64
"\n",
stats->value->stats->rd_bytes,
stats->value->stats->wr_bytes,
@@ -482,7 +484,9 @@ void hmp_info_blockstats(Monitor *mon, const QDict *qdict)
stats->value->stats->flush_operations,
stats->value->stats->wr_total_time_ns,
stats->value->stats->rd_total_time_ns,
- stats->value->stats->flush_total_time_ns);
+ stats->value->stats->flush_total_time_ns,
+ stats->value->stats->rd_merged,
+ stats->value->stats->wr_merged);
}
qapi_free_BlockStatsList(stats_list);
diff --git a/include/block/accounting.h b/include/block/accounting.h
index 50b42b3..4c406cf 100644
--- a/include/block/accounting.h
+++ b/include/block/accounting.h
@@ -39,6 +39,7 @@ typedef struct BlockAcctStats {
uint64_t nr_bytes[BLOCK_MAX_IOTYPE];
uint64_t nr_ops[BLOCK_MAX_IOTYPE];
uint64_t total_time_ns[BLOCK_MAX_IOTYPE];
+ uint64_t merged[BLOCK_MAX_IOTYPE];
uint64_t wr_highest_sector;
} BlockAcctStats;
@@ -53,5 +54,7 @@ void block_acct_start(BlockAcctStats *stats, BlockAcctCookie
*cookie,
void block_acct_done(BlockAcctStats *stats, BlockAcctCookie *cookie);
void block_acct_highest_sector(BlockAcctStats *stats, int64_t sector_num,
unsigned int nb_sectors);
+void block_acct_merge_done(BlockAcctStats *stats, enum BlockAcctType type,
+ int num_requests);
#endif
diff --git a/qapi/block-core.json b/qapi/block-core.json
index 80984d1..b7d9772 100644
--- a/qapi/block-core.json
+++ b/qapi/block-core.json
@@ -407,13 +407,20 @@
# growable sparse files (like qcow2) that are used on top
# of a physical device.
#
+# @rd_merged: Number of read requests that have been merged into another
+# request (Since 2.3).
+#
+# @wr_merged: Number of write requests that have been merged into another
+# request (Since 2.3).
+#
# Since: 0.14.0
##
{ 'type': 'BlockDeviceStats',
'data': {'rd_bytes': 'int', 'wr_bytes': 'int', 'rd_operations': 'int',
'wr_operations': 'int', 'flush_operations': 'int',
'flush_total_time_ns': 'int', 'wr_total_time_ns': 'int',
- 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int' } }
+ 'rd_total_time_ns': 'int', 'wr_highest_offset': 'int',
+ 'rd_merged': 'int', 'wr_merged': 'int' } }
##
# @BlockStats:
diff --git a/qmp-commands.hx b/qmp-commands.hx
index c5f16dd..af3fd19 100644
--- a/qmp-commands.hx
+++ b/qmp-commands.hx
@@ -2303,6 +2303,10 @@ Each json-object contain the following:
- "flush_total_time_ns": total time spend on cache flushes in nano-seconds
(json-int)
- "wr_highest_offset": Highest offset of a sector written since the
BlockDriverState has been opened (json-int)
+ - "rd_merged": number of read requests that have been merged into
+ another request (json-int)
+ - "wr_merged": number of write requests that have been merged into
+ another request (json-int)
- "parent": Contains recursively the statistics of the underlying
protocol (e.g. the host file for a qcow2 image). If there is
no underlying protocol, this field is omitted
@@ -2326,6 +2330,8 @@ Example:
"rd_total_times_ns":3465673657
"flush_total_times_ns":49653
"flush_operations":61,
+ "rd_merged":0,
+ "wr_merged":0
}
},
"stats":{
@@ -2337,7 +2343,9 @@ Example:
"flush_operations":51,
"wr_total_times_ns":313253456
"rd_total_times_ns":3465673657
- "flush_total_times_ns":49653
+ "flush_total_times_ns":49653,
+ "rd_merged":0,
+ "wr_merged":0
}
},
{
@@ -2351,7 +2359,9 @@ Example:
"flush_operations":0,
"wr_total_times_ns":0
"rd_total_times_ns":0
- "flush_total_times_ns":0
+ "flush_total_times_ns":0,
+ "rd_merged":0,
+ "wr_merged":0
}
},
{
@@ -2365,7 +2375,9 @@ Example:
"flush_operations":0,
"wr_total_times_ns":0
"rd_total_times_ns":0
- "flush_total_times_ns":0
+ "flush_total_times_ns":0,
+ "rd_merged":0,
+ "wr_merged":0
}
},
{
@@ -2379,7 +2391,9 @@ Example:
"flush_operations":0,
"wr_total_times_ns":0
"rd_total_times_ns":0
- "flush_total_times_ns":0
+ "flush_total_times_ns":0,
+ "rd_merged":0,
+ "wr_merged":0
}
}
]
--
1.8.3.1
- [Qemu-devel] [PULL 07/42] block/raw-posix: call plain fallocate in handle_aiocb_write_zeroes, (continued)
- [Qemu-devel] [PULL 07/42] block/raw-posix: call plain fallocate in handle_aiocb_write_zeroes, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 03/42] block/raw-posix: create translate_err helper to merge errno values, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 04/42] block/raw-posix: create do_fallocate helper, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 02/42] atapi migration: Throw recoverable error to avoid recovery, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 10/42] qemu-img: Add QEMU_PKGVERSION to QEMU_IMG_VERSION, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 06/42] block: use fallocate(FALLOC_FL_ZERO_RANGE) in handle_aiocb_write_zeroes, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 09/42] block: change default for discard and write zeroes to INT_MAX, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 08/42] block: use fallocate(FALLOC_FL_PUNCH_HOLE) & fallocate(0) to write zeroes, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 13/42] hw/virtio-blk: add a constant for max number of merged requests, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 11/42] qed: Really remove unused field QEDAIOCB.finished, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 12/42] block: add accounting for merged requests,
Kevin Wolf <=
- [Qemu-devel] [PULL 14/42] block-backend: expose bs->bl.max_transfer_length, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 17/42] qemu-iotests: Fix supported_oses check, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 15/42] virtio-blk: introduce multiread, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 18/42] iotests: Specify format for qemu-nbd, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 20/42] block/dmg: properly detect the UDIF trailer, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 16/42] virtio-blk: add a knob to disable request merging, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 22/42] block/dmg: extract processing of resource forks, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 25/42] block/dmg: process XML plists, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 19/42] block: add event when disk usage exceeds threshold, Kevin Wolf, 2015/02/06
- [Qemu-devel] [PULL 26/42] block/dmg: set virtual size to a non-zero value, Kevin Wolf, 2015/02/06