From 76f4afb40fa076ed23fe0ab42c7a768ddb71123f Mon Sep 17 00:00:00 2001 From: Alberto Garcia Date: Mon, 8 Jun 2015 18:17:44 +0200 Subject: throttle: Add throttle group support The throttle group support use a cooperative round robin scheduling algorithm. The principles of the algorithm are simple: - Each BDS of the group is used as a token in a circular way. - The active BDS computes if a wait must be done and arms the right timer. - If a wait must be done the token timer will be armed so the token will become the next active BDS. Signed-off-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi Message-id: f0082a86f3ac01c46170f7eafe2101a92e8fde39.1433779731.git.berto@igalia.com Signed-off-by: Stefan Hajnoczi --- include/block/block.h | 3 ++- include/block/block_int.h | 7 +++++-- include/block/throttle-groups.h | 4 ++++ 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'include/block') diff --git a/include/block/block.h b/include/block/block.h index f7680b6e68..f6fb8c497b 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -173,8 +173,9 @@ void bdrv_stats_print(Monitor *mon, const QObject *data); void bdrv_info_stats(Monitor *mon, QObject **ret_data); /* disk I/O throttling */ -void bdrv_io_limits_enable(BlockDriverState *bs); +void bdrv_io_limits_enable(BlockDriverState *bs, const char *group); void bdrv_io_limits_disable(BlockDriverState *bs); +void bdrv_io_limits_update_group(BlockDriverState *bs, const char *group); void bdrv_init(void); void bdrv_init_with_whitelist(void); diff --git a/include/block/block_int.h b/include/block/block_int.h index 8d15c7b680..b174852099 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -379,10 +379,13 @@ struct BlockDriverState { unsigned int serialising_in_flight; /* I/O throttling */ - ThrottleState throttle_state; - ThrottleTimers throttle_timers; CoQueue throttled_reqs[2]; bool io_limits_enabled; + /* The following fields are protected by the ThrottleGroup lock. + * See the ThrottleGroup documentation for details. */ + ThrottleState *throttle_state; + ThrottleTimers throttle_timers; + unsigned pending_reqs[2]; QLIST_ENTRY(BlockDriverState) round_robin; /* I/O stats (display with "info blockstats"). */ diff --git a/include/block/throttle-groups.h b/include/block/throttle-groups.h index b966ec793c..322139a7a2 100644 --- a/include/block/throttle-groups.h +++ b/include/block/throttle-groups.h @@ -36,4 +36,8 @@ void throttle_group_get_config(BlockDriverState *bs, ThrottleConfig *cfg); void throttle_group_register_bs(BlockDriverState *bs, const char *groupname); void throttle_group_unregister_bs(BlockDriverState *bs); +void coroutine_fn throttle_group_co_io_limits_intercept(BlockDriverState *bs, + unsigned int bytes, + bool is_write); + #endif -- cgit v1.2.3