diff mbox

[6/9] throttle: Add a way to fire one of the timers asap like a bottom half

Message ID 0c82eae548bb7d0dfe2e110876f7df9bd4cb3252.1423842044.git.berto@igalia.com
State New
Headers show

Commit Message

Alberto Garcia Feb. 13, 2015, 4:06 p.m. UTC
From: BenoƮt Canet <benoit.canet@nodalink.com>

This will be needed by the group throttling algorithm.

Signed-off-by: Benoit Canet <benoit.canet@nodalink.com>
Signed-off-by: Alberto Garcia <berto@igalia.com>
---
 include/qemu/throttle.h |  2 ++
 util/throttle.c         | 11 +++++++++++
 2 files changed, 13 insertions(+)

Comments

Stefan Hajnoczi March 3, 2015, 5:08 p.m. UTC | #1
On Fri, Feb 13, 2015 at 06:06:14PM +0200, Alberto Garcia wrote:
> diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
> index 69aa7c2..f846e5a 100644
> --- a/include/qemu/throttle.h
> +++ b/include/qemu/throttle.h
> @@ -127,6 +127,8 @@ bool throttle_schedule_timer(ThrottleState *ts,
>                               bool is_write,
>                               bool *armed);
>  
> +void throttle_fire_timer(ThrottleTimers *tt, bool is_write);
> +
>  void throttle_timer_fired(ThrottleState *ts, bool is_write);
>  
>  void throttle_account(ThrottleState *ts, bool is_write, uint64_t size);

General feeling when seeing this patch:

This is a little weird because suddenly we're dealing directly with
ThrottleTimers instead of ThrottleState or ThrottleGroup.  Also, it
doesn't set any_timers_pending[], maybe that could be a problem.
diff mbox

Patch

diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
index 69aa7c2..f846e5a 100644
--- a/include/qemu/throttle.h
+++ b/include/qemu/throttle.h
@@ -127,6 +127,8 @@  bool throttle_schedule_timer(ThrottleState *ts,
                              bool is_write,
                              bool *armed);
 
+void throttle_fire_timer(ThrottleTimers *tt, bool is_write);
+
 void throttle_timer_fired(ThrottleState *ts, bool is_write);
 
 void throttle_account(ThrottleState *ts, bool is_write, uint64_t size);
diff --git a/util/throttle.c b/util/throttle.c
index f5cd564..4219ace 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -402,6 +402,17 @@  bool throttle_schedule_timer(ThrottleState *ts,
     return true;
 }
 
+/* Schedule a throttle timer like a BH
+ *
+ * @tt:       The timers structure
+ * @is_write: the type of operation (read/write)
+ */
+void throttle_fire_timer(ThrottleTimers *tt, bool is_write)
+{
+    int64_t now = qemu_clock_get_ns(tt->clock_type);
+    timer_mod(tt->timers[is_write], now + 1);
+}
+
 /* Remember that now timers are currently armed
  *
  * @ts:       the throttle state we are working on