From: "Benoît Canet" <benoit@irqsave.net>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, "Benoît Canet" <benoit@irqsave.net>,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH V2 for-1.6 5/5] block: Add throttling percentage metrics.
Date: Tue, 23 Jul 2013 14:21:07 +0200 [thread overview]
Message-ID: <1374582067-9063-6-git-send-email-benoit@irqsave.net> (raw)
In-Reply-To: <1374582067-9063-1-git-send-email-benoit@irqsave.net>
This metrics show how many percent of the time I/Os are put on hold by the
throttling algorithm.
This metric could be used by system administrators or cloud stack developpers
to decide when the throttling settings must be changed.
Signed-off-by: Benoit Canet <benoit@irqsave.net>
---
block.c | 17 ++++++++++++++++-
block/qapi.c | 4 ++++
hmp.c | 6 ++++--
include/block/block_int.h | 2 ++
qapi-schema.json | 4 +++-
5 files changed, 29 insertions(+), 4 deletions(-)
diff --git a/block.c b/block.c
index cfa890d..749f276 100644
--- a/block.c
+++ b/block.c
@@ -130,6 +130,8 @@ void bdrv_io_limits_disable(BlockDriverState *bs)
qemu_free_timer(bs->block_timer);
bs->block_timer = NULL;
}
+ bs->throttling_percentage = 0;
+ bs->full_since = 0;
}
static void bdrv_make_bps_buckets_leak(BlockDriverState *bs, int64_t delta)
@@ -219,7 +221,8 @@ static void bdrv_make_iops_buckets_leak(BlockDriverState *bs, int64_t delta)
static void bdrv_leak_if_needed(BlockDriverState *bs)
{
int64_t now;
- int64_t delta;
+ int64_t delta; /* the delta that would be ideally the timer period */
+ int64_t delta_full; /* the delta where the bucket is full */
if (!bs->must_leak) {
return;
@@ -229,6 +232,11 @@ static void bdrv_leak_if_needed(BlockDriverState *bs)
now = qemu_get_clock_ns(rt_clock);
delta = now - bs->previous_leak;
+ /* compute throttle percentage reflecting how long IO are hold on average */
+ if (bs->full_since) {
+ delta_full = now - bs->full_since;
+ bs->throttling_percentage = (delta_full * 100) / delta;
+ }
bs->previous_leak = now;
bdrv_make_bps_buckets_leak(bs, delta);
@@ -255,6 +263,8 @@ void bdrv_io_limits_enable(BlockDriverState *bs)
bs->block_timer = qemu_new_timer_ns(vm_clock, bdrv_block_timer, bs);
bs->io_limits_enabled = true;
bs->previous_leak = qemu_get_clock_ns(rt_clock);
+ bs->throttling_percentage = 0;
+ bs->full_since = 0;
qemu_mod_timer(bs->block_timer,
qemu_get_clock_ns(vm_clock) +
BLOCK_IO_THROTTLE_PERIOD);
@@ -396,6 +406,11 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
* not full
*/
while (bdrv_is_any_threshold_exceeded(bs, nb_sectors, is_write)) {
+ /* remember since when the code decided to block the first I/O */
+ if (qemu_co_queue_empty(&bs->throttled_reqs)) {
+ bs->full_since = qemu_get_clock_ns(rt_clock);
+ }
+
bdrv_leak_if_needed(bs);
qemu_co_queue_wait_insert_head(&bs->throttled_reqs);
bdrv_leak_if_needed(bs);
diff --git a/block/qapi.c b/block/qapi.c
index f81081c..bd1c6af 100644
--- a/block/qapi.c
+++ b/block/qapi.c
@@ -263,6 +263,10 @@ void bdrv_query_info(BlockDriverState *bs,
bs->io_limits.iops_sector_count;
info->inserted->iops_sector_count =
bs->io_limits.iops_sector_count;
+ info->inserted->has_throttling_percentage =
+ bs->throttling_percentage;
+ info->inserted->throttling_percentage =
+ bs->throttling_percentage;
}
bs0 = bs;
diff --git a/hmp.c b/hmp.c
index 3912305..9dc4862 100644
--- a/hmp.c
+++ b/hmp.c
@@ -348,7 +348,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
" iops_threshold=%" PRId64
" iops_rd_threshold=%" PRId64
" iops_wr_threshold=%" PRId64
- " iops_sector_count=%" PRId64 "\n",
+ " iops_sector_count=%" PRId64
+ " throttling_percentage=%" PRId64 "\n",
info->value->inserted->bps,
info->value->inserted->bps_rd,
info->value->inserted->bps_wr,
@@ -361,7 +362,8 @@ void hmp_info_block(Monitor *mon, const QDict *qdict)
info->value->inserted->iops_threshold,
info->value->inserted->iops_rd_threshold,
info->value->inserted->iops_wr_threshold,
- info->value->inserted->iops_sector_count);
+ info->value->inserted->iops_sector_count,
+ info->value->inserted->throttling_percentage);
} else {
monitor_printf(mon, " [not inserted]");
}
diff --git a/include/block/block_int.h b/include/block/block_int.h
index 74d7503..4487cd9 100644
--- a/include/block/block_int.h
+++ b/include/block/block_int.h
@@ -271,6 +271,8 @@ struct BlockDriverState {
BlockIOLimit io_limits;
BlockIOBaseValue leaky_buckets;
int64_t previous_leak;
+ int64_t full_since;
+ int throttling_percentage;
bool must_leak;
CoQueue throttled_reqs;
QEMUTimer *block_timer;
diff --git a/qapi-schema.json b/qapi-schema.json
index d579fda..14a02e7 100644
--- a/qapi-schema.json
+++ b/qapi-schema.json
@@ -783,6 +783,8 @@
#
# @iops_sector_count: #optional an I/O size in sector (Since 1.6)
#
+# @throttling_percentage: #optional reflect throttling activity (Since 1.6)
+#
# Since: 0.14.0
#
# Notes: This interface is only found in @BlockInfo.
@@ -797,7 +799,7 @@
'*bps_threshold': 'int', '*bps_rd_threshold': 'int',
'*bps_wr_threshold': 'int', '*iops_threshold': 'int',
'*iops_rd_threshold': 'int', '*iops_wr_threshold': 'int',
- '*iops_sector_count': 'int' } }
+ '*iops_sector_count': 'int', '*throttling_percentage': 'int' } }
##
# @BlockDeviceIoStatus:
--
1.7.10.4
prev parent reply other threads:[~2013-07-23 12:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-23 12:21 [Qemu-devel] [PATCH V2 for-1.6 0/5] Leaky bucket throttling and features Benoît Canet
2013-07-23 12:21 ` [Qemu-devel] [PATCH V2 for-1.6 1/5] block: Repair the throttling code Benoît Canet
2013-07-23 14:31 ` Stefan Hajnoczi
2013-07-23 12:21 ` [Qemu-devel] [PATCH V2 for-1.6 2/5] block: Modify the throttling code to implement the leaky bucket algorithm Benoît Canet
2013-07-23 14:59 ` Stefan Hajnoczi
2013-07-23 15:14 ` Benoît Canet
2013-07-23 15:20 ` Benoît Canet
2013-07-23 12:21 ` [Qemu-devel] [PATCH V2 for-1.6 3/5] block: Add support for throttling burst threshold in QMP and the command line Benoît Canet
2013-07-23 12:21 ` [Qemu-devel] [PATCH V2 for-1.6 4/5] block: Add iops_sector_count to do the iops accounting for a given io size Benoît Canet
2013-07-23 12:21 ` Benoît Canet [this message]
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=1374582067-9063-6-git-send-email-benoit@irqsave.net \
--to=benoit@irqsave.net \
--cc=kwolf@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).