From: "Benoît Canet" <benoit.canet@nodalink.com>
To: qemu-devel@nongnu.org
Cc: kwolf@redhat.com, famz@redhat.com,
"Benoît Canet" <benoit.canet@nodalink.com>,
stefanha@redhat.com
Subject: [Qemu-devel] [PATCH v1 5/8] throttle: Add a way to know if throttle_schedule_timer had armed a timer
Date: Tue, 7 Oct 2014 15:24:36 +0200 [thread overview]
Message-ID: <1412688279-8312-6-git-send-email-benoit.canet@nodalink.com> (raw)
In-Reply-To: <1412688279-8312-1-git-send-email-benoit.canet@nodalink.com>
This will be needed by the group throttling patches for the algorithm to be
accurate.
Signed-off-by: Benoit Canet <benoit.canet@nodalink.com>
---
block.c | 7 +++++--
include/qemu/throttle.h | 3 ++-
util/throttle.c | 12 +++++++-----
3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/block.c b/block.c
index 079b0dc..527ea48 100644
--- a/block.c
+++ b/block.c
@@ -202,10 +202,13 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
unsigned int bytes,
bool is_write)
{
+ bool armed;
+
/* does this io must wait */
bool must_wait = throttle_schedule_timer(&bs->throttle_state,
&bs->throttle_timers,
- is_write);
+ is_write,
+ &armed);
/* if must wait or any request of this type throttled queue the IO */
if (must_wait ||
@@ -219,7 +222,7 @@ static void bdrv_io_limits_intercept(BlockDriverState *bs,
/* if the next request must wait -> do nothing */
if (throttle_schedule_timer(&bs->throttle_state, &bs->throttle_timers,
- is_write)) {
+ is_write, &armed)) {
return;
}
diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
index 3aece3a..3a16c48 100644
--- a/include/qemu/throttle.h
+++ b/include/qemu/throttle.h
@@ -124,7 +124,8 @@ void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg);
/* usage */
bool throttle_schedule_timer(ThrottleState *ts,
ThrottleTimers *tt,
- bool is_write);
+ bool is_write,
+ bool *armed);
void throttle_timer_fired(ThrottleState *ts, bool is_write);
diff --git a/util/throttle.c b/util/throttle.c
index 0e305e3..a273acb 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -375,11 +375,13 @@ void throttle_get_config(ThrottleState *ts, ThrottleConfig *cfg)
*/
bool throttle_schedule_timer(ThrottleState *ts,
ThrottleTimers *tt,
- bool is_write)
+ bool is_write,
+ bool *armed)
{
int64_t now = qemu_clock_get_ns(tt->clock_type);
int64_t next_timestamp;
bool must_wait;
+ *armed = false;
must_wait = throttle_compute_timer(ts,
is_write,
@@ -392,12 +394,12 @@ bool throttle_schedule_timer(ThrottleState *ts,
}
/* request throttled and any timer pending -> do nothing */
- if (ts->any_timer_armed[is_write]) {
- return true;
+ if (!ts->any_timer_armed[is_write]) {
+ *armed = true;
+ ts->any_timer_armed[is_write] = true;
+ timer_mod(tt->timers[is_write], next_timestamp);
}
- ts->any_timer_armed[is_write] = true;
- timer_mod(tt->timers[is_write], next_timestamp);
return true;
}
--
2.1.1
next prev parent reply other threads:[~2014-10-07 13:27 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-07 13:24 [Qemu-devel] [PATCH v1 0/8] Block Throttle Group Support Benoît Canet
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 1/8] throttle: Extract timers from ThrottleState into a separate ThrottleTimers structure Benoît Canet
2014-10-08 5:51 ` Fam Zheng
2014-10-08 15:06 ` Eric Blake
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 2/8] throttle: Add throttle group infrastructure Benoît Canet
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 3/8] throttle: Add throttle group infrastructure tests Benoît Canet
2014-10-08 6:20 ` Fam Zheng
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 4/8] throttle: Prepare to have multiple timers for one ThrottleState Benoît Canet
2014-10-07 13:24 ` Benoît Canet [this message]
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 6/8] throttle: Add a way to fire one of the timers asap like a bottom half Benoît Canet
2014-10-08 6:26 ` Fam Zheng
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 7/8] throttle: Add throttle group support Benoît Canet
2014-10-08 6:53 ` Fam Zheng
2014-10-08 11:05 ` Benoît Canet
2014-10-09 8:58 ` Fam Zheng
2014-10-10 11:35 ` Benoît Canet
2014-10-07 13:24 ` [Qemu-devel] [PATCH v1 8/8] throttle: Update throttle infrastructure copyright Benoît Canet
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=1412688279-8312-6-git-send-email-benoit.canet@nodalink.com \
--to=benoit.canet@nodalink.com \
--cc=famz@redhat.com \
--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).