diff mbox

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

Message ID 1412688279-8312-7-git-send-email-benoit.canet@nodalink.com
State New
Headers show

Commit Message

Benoît Canet Oct. 7, 2014, 1:24 p.m. UTC
This will be needed by the group throttling algorithm.

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

Comments

Fam Zheng Oct. 8, 2014, 6:26 a.m. UTC | #1
On Tue, 10/07 15:24, Benoît Canet wrote:
> This will be needed by the group throttling algorithm.
> 
> Signed-off-by: Benoit Canet <benoit.canet@nodalink.com>
> ---
>  include/qemu/throttle.h |  2 ++
>  util/throttle.c         | 11 +++++++++++
>  2 files changed, 13 insertions(+)
> 
> diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
> index 3a16c48..3b9d1b8 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 a273acb..163b9d0 100644
> --- a/util/throttle.c
> +++ b/util/throttle.c
> @@ -403,6 +403,17 @@ bool throttle_schedule_timer(ThrottleState *ts,
>      return true;
>  }
>  
> +/* Schedule a throttle timer like a BH

Why not use a real BH? It's more efficient than a timer scheduled at now + 1.

Fam

> + *
> + * @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
> -- 
> 2.1.1
>
diff mbox

Patch

diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h
index 3a16c48..3b9d1b8 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 a273acb..163b9d0 100644
--- a/util/throttle.c
+++ b/util/throttle.c
@@ -403,6 +403,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