[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 5/9] throttle: Add a way to know if throttle_schedul
From: |
Alberto Garcia |
Subject: |
[Qemu-devel] [PATCH 5/9] throttle: Add a way to know if throttle_schedule_timer had armed a timer |
Date: |
Fri, 13 Feb 2015 18:06:13 +0200 |
From: BenoƮt Canet <address@hidden>
This will be needed by the group throttling patches for the algorithm to be
accurate.
Signed-off-by: Benoit Canet <address@hidden>
Signed-off-by: Alberto Garcia <address@hidden>
---
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 fb45c6e..642ef04 100644
--- a/block.c
+++ b/block.c
@@ -203,10 +203,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 ||
@@ -220,7 +223,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 546ba12..69aa7c2 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 71770d3..f5cd564 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -374,11 +374,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,
@@ -391,12 +393,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.4
- [Qemu-devel] [PATCH v2 0/9] Block Throttle Group Support, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 6/9] throttle: Add a way to fire one of the timers asap like a bottom half, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 8/9] throttle: Update throttle infrastructure copyright, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 3/9] throttle: Add throttle group infrastructure tests, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 9/9] throttle: add name of ThrottleGroup to BlockDeviceInfo, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 4/9] throttle: Prepare to have multiple timers for one ThrottleState, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 5/9] throttle: Add a way to know if throttle_schedule_timer had armed a timer,
Alberto Garcia <=
- [Qemu-devel] [PATCH 7/9] throttle: Add throttle group support, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 2/9] throttle: Add throttle group infrastructure, Alberto Garcia, 2015/02/13
- [Qemu-devel] [PATCH 1/9] throttle: Extract timers from ThrottleState into a separate ThrottleTimers structure, Alberto Garcia, 2015/02/13