From: Christoph Hellwig <hch@lst.de>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH 3/3] block: latency accounting
Date: Fri, 12 Aug 2011 01:44:36 +0200 [thread overview]
Message-ID: <20110811234436.GC19502@lst.de> (raw)
In-Reply-To: <20110811234411.GA19487@lst.de>
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>
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c 2011-08-04 16:09:22.656913900 +0200
+++ qemu/block.c 2011-08-04 16:11:14.746306661 +0200
@@ -1790,12 +1790,18 @@ static void bdrv_stats_iter(QObject *dat
" 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)
@@ -1814,7 +1820,10 @@ static QObject* bdrv_info_stats_bs(Block
"'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],
@@ -1822,7 +1831,10 @@ static QObject* bdrv_info_stats_bs(Block
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_READ],
+ bs->total_time_ns[BDRV_ACCT_WRITE],
+ bs->total_time_ns[BDRV_ACCT_FLUSH]);
dict = qobject_to_qdict(res);
if (*bs->device_name) {
Index: qemu/block_int.h
===================================================================
--- qemu.orig/block_int.h 2011-08-04 16:07:42.614122545 +0200
+++ qemu/block_int.h 2011-08-04 16:11:42.752821602 +0200
@@ -27,6 +27,7 @@
#include "block.h"
#include "qemu-option.h"
#include "qemu-queue.h"
+#include "qemu-timer.h"
#define BLOCK_FLAG_ENCRYPT 1
#define BLOCK_FLAG_COMPAT6 4
@@ -187,6 +188,7 @@ struct BlockDriverState {
/* I/O stats (display with "info blockstats"). */
uint64_t nr_bytes[BDRV_MAX_IOTYPE];
uint64_t nr_ops[BDRV_MAX_IOTYPE];
+ uint64_t total_time_ns[BDRV_MAX_IOTYPE];
uint64_t wr_highest_sector;
/* Whether the disk can expand beyond total_sectors */
@@ -212,6 +214,7 @@ struct BlockDriverState {
typedef struct BlockAcctCookie {
int64_t bytes;
+ int64_t start_time_ns;
enum BlockIOType type;
} BlockAcctCookie;
@@ -221,6 +224,7 @@ bdrv_acct_start(BlockDriverState *bs, Bl
{
cookie->bytes = bytes;
cookie->type = type;
+ cookie->start_time_ns = get_clock();
}
static inline void
@@ -228,6 +232,7 @@ bdrv_acct_done(BlockDriverState *bs, Blo
{
bs->nr_bytes[cookie->type] += cookie->bytes;
bs->nr_ops[cookie->type]++;
+ bs->total_time_ns[cookie->type] += get_clock() - cookie->start_time_ns;
}
Index: qemu/qmp-commands.hx
===================================================================
--- qemu.orig/qmp-commands.hx 2011-08-04 16:13:37.912197731 +0200
+++ qemu/qmp-commands.hx 2011-08-04 16:16:06.034728615 +0200
@@ -1202,6 +1202,9 @@ Each json-object contain the following:
- "rd_operations": read operations (json-int)
- "wr_operations": write operations (json-int)
- "flush_operations": cache flush operations (json-int)
+ - "wr_total_time_ns": total time spend on writes in nano-seconds (json-int)
+ - "rd_total_time_ns": total time spend on reads in nano-seconds (json-int)
+ - "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)
- "parent": Contains recursively the statistics of the underlying
@@ -1223,6 +1226,9 @@ Example:
"wr_operations":751,
"rd_bytes":122567168,
"rd_operations":36772
+ "wr_total_times_ns":313253456
+ "rd_total_times_ns":3465673657
+ "flush_total_times_ns":49653
"flush_operations":61,
}
},
@@ -1233,6 +1239,9 @@ Example:
"rd_bytes":122739200,
"rd_operations":36604
"flush_operations":51,
+ "wr_total_times_ns":313253456
+ "rd_total_times_ns":3465673657
+ "flush_total_times_ns":49653
}
},
{
@@ -1244,6 +1253,9 @@ Example:
"rd_bytes":0,
"rd_operations":0
"flush_operations":0,
+ "wr_total_times_ns":0
+ "rd_total_times_ns":0
+ "flush_total_times_ns":0
}
},
{
@@ -1255,6 +1267,9 @@ Example:
"rd_bytes":0,
"rd_operations":0
"flush_operations":0,
+ "wr_total_times_ns":0
+ "rd_total_times_ns":0
+ "flush_total_times_ns":0
}
},
{
@@ -1266,6 +1281,9 @@ Example:
"rd_bytes":0,
"rd_operations":0
"flush_operations":0,
+ "wr_total_times_ns":0
+ "rd_total_times_ns":0
+ "flush_total_times_ns":0
}
}
]
next prev parent reply other threads:[~2011-08-11 23:44 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-11 23:44 [Qemu-devel] [PATCH 0/3] better I/O accounting Christoph Hellwig
2011-08-11 23:44 ` [Qemu-devel] [PATCH 1/3] block: include flush requests in info blockstats Christoph Hellwig
2011-08-11 23:44 ` [Qemu-devel] [PATCH 2/3] block: explicit I/O accounting Christoph Hellwig
2011-08-11 23:44 ` Christoph Hellwig [this message]
2011-08-12 5:14 ` [Qemu-devel] [PATCH 0/3] better " Stefan Hajnoczi
2011-08-12 5:50 ` Stefan Hajnoczi
2011-08-12 13:40 ` Christoph Hellwig
-- strict thread matches above, loose matches on Subject: below --
2011-08-21 22:25 [Qemu-devel] [PATCH 0/3] better I/O accounting V2 Christoph Hellwig
2011-08-21 22:26 ` [Qemu-devel] [PATCH 3/3] block: latency accounting Christoph Hellwig
2011-08-25 6:25 ` [Qemu-devel] [PATCH 0/3] better I/O accounting V3 Christoph Hellwig
2011-08-25 6:26 ` [Qemu-devel] [PATCH 3/3] block: latency accounting Christoph Hellwig
2011-08-26 13:05 ` Kevin Wolf
2011-08-26 16:06 ` Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20110811234436.GC19502@lst.de \
--to=hch@lst.de \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).