From: Greg Kurz <groug@kaod.org>
To: Pradeep Jagadeesh <pradeepkiruvale@gmail.com>
Cc: eric blake <eblake@redhat.com>,
Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>,
alberto garcia <berto@igalia.com>,
Markus Armbruster <armbru@redhat.com>,
jani kokkonen <jani.kokkonen@huawei.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v10 3/6] throttle: move out function to reuse the code
Date: Fri, 8 Sep 2017 14:27:29 +0200 [thread overview]
Message-ID: <20170908142729.1008e033@bahia> (raw)
In-Reply-To: <1504541267-36954-4-git-send-email-pradeep.jagadeesh@huawei.com>
[-- Attachment #1: Type: text/plain, Size: 6561 bytes --]
On Mon, 4 Sep 2017 12:07:44 -0400
Pradeep Jagadeesh <pradeepkiruvale@gmail.com> wrote:
> This patch move out the throttle code to util/throttle.c to maximize
> the reusability of the code.The same code is also used by fsdev.
s/.The same code is also used by fsdev/. The same code will also be used by fsdev/
> Signed-off-by: Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
> Reviewed-by: Alberto Garcia <berto@igalia.com>
Reviewed-by: Greg Kurz <groug@kaod.org>
> ---
> blockdev.c | 53 +++---------------------------------
> include/qemu/throttle-options.h | 2 ++
> util/throttle.c | 59 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 64 insertions(+), 50 deletions(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 780ae58..1caf2e0 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -2571,6 +2571,7 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
> BlockDriverState *bs;
> BlockBackend *blk;
> AioContext *aio_context;
> + IOThrottle *iothrottle;
>
> blk = qmp_get_blk(arg->has_device ? arg->device : NULL,
> arg->has_id ? arg->id : NULL,
> @@ -2588,56 +2589,8 @@ void qmp_block_set_io_throttle(BlockIOThrottle *arg, Error **errp)
> goto out;
> }
>
> - throttle_config_init(&cfg);
> - cfg.buckets[THROTTLE_BPS_TOTAL].avg = arg->bps;
> - cfg.buckets[THROTTLE_BPS_READ].avg = arg->bps_rd;
> - cfg.buckets[THROTTLE_BPS_WRITE].avg = arg->bps_wr;
> -
> - cfg.buckets[THROTTLE_OPS_TOTAL].avg = arg->iops;
> - cfg.buckets[THROTTLE_OPS_READ].avg = arg->iops_rd;
> - cfg.buckets[THROTTLE_OPS_WRITE].avg = arg->iops_wr;
> -
> - if (arg->has_bps_max) {
> - cfg.buckets[THROTTLE_BPS_TOTAL].max = arg->bps_max;
> - }
> - if (arg->has_bps_rd_max) {
> - cfg.buckets[THROTTLE_BPS_READ].max = arg->bps_rd_max;
> - }
> - if (arg->has_bps_wr_max) {
> - cfg.buckets[THROTTLE_BPS_WRITE].max = arg->bps_wr_max;
> - }
> - if (arg->has_iops_max) {
> - cfg.buckets[THROTTLE_OPS_TOTAL].max = arg->iops_max;
> - }
> - if (arg->has_iops_rd_max) {
> - cfg.buckets[THROTTLE_OPS_READ].max = arg->iops_rd_max;
> - }
> - if (arg->has_iops_wr_max) {
> - cfg.buckets[THROTTLE_OPS_WRITE].max = arg->iops_wr_max;
> - }
> -
> - if (arg->has_bps_max_length) {
> - cfg.buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_max_length;
> - }
> - if (arg->has_bps_rd_max_length) {
> - cfg.buckets[THROTTLE_BPS_READ].burst_length = arg->bps_rd_max_length;
> - }
> - if (arg->has_bps_wr_max_length) {
> - cfg.buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_wr_max_length;
> - }
> - if (arg->has_iops_max_length) {
> - cfg.buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_max_length;
> - }
> - if (arg->has_iops_rd_max_length) {
> - cfg.buckets[THROTTLE_OPS_READ].burst_length = arg->iops_rd_max_length;
> - }
> - if (arg->has_iops_wr_max_length) {
> - cfg.buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_wr_max_length;
> - }
> -
> - if (arg->has_iops_size) {
> - cfg.op_size = arg->iops_size;
> - }
> + iothrottle = qapi_BlockIOThrottle_base(arg);
> + throttle_set_io_limits(&cfg, iothrottle);
>
> if (!throttle_is_valid(&cfg, errp)) {
> goto out;
> diff --git a/include/qemu/throttle-options.h b/include/qemu/throttle-options.h
> index f63d38c..b736185 100644
> --- a/include/qemu/throttle-options.h
> +++ b/include/qemu/throttle-options.h
> @@ -11,6 +11,7 @@
> #define THROTTLE_OPTIONS_H
>
> #include "typedefs.h"
> +#include "qapi-types.h"
>
> #define THROTTLE_OPTS \
> { \
> @@ -92,5 +93,6 @@
> }
>
> void throttle_parse_options(ThrottleConfig *, QemuOpts *);
> +void throttle_set_io_limits(ThrottleConfig *, IOThrottle *);
>
> #endif
> diff --git a/util/throttle.c b/util/throttle.c
> index 95c2ecf..dcc9d5a 100644
> --- a/util/throttle.c
> +++ b/util/throttle.c
> @@ -553,3 +553,62 @@ void throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts)
> throttle_cfg->op_size =
> qemu_opt_get_number(opts, "throttling.iops-size", 0);
> }
> +
> +/* Initialize a throttle config from an IOThrottle structure
> + *
> + * @arg: iothrottle limits
> + * @cfg: throttle configuration
> + */
> +void throttle_set_io_limits(ThrottleConfig *cfg, IOThrottle *arg)
> +{
> + throttle_config_init(cfg);
> + cfg->buckets[THROTTLE_BPS_TOTAL].avg = arg->bps;
> + cfg->buckets[THROTTLE_BPS_READ].avg = arg->bps_rd;
> + cfg->buckets[THROTTLE_BPS_WRITE].avg = arg->bps_wr;
> +
> + cfg->buckets[THROTTLE_OPS_TOTAL].avg = arg->iops;
> + cfg->buckets[THROTTLE_OPS_READ].avg = arg->iops_rd;
> + cfg->buckets[THROTTLE_OPS_WRITE].avg = arg->iops_wr;
> +
> + if (arg->has_bps_max) {
> + cfg->buckets[THROTTLE_BPS_TOTAL].max = arg->bps_max;
> + }
> + if (arg->has_bps_rd_max) {
> + cfg->buckets[THROTTLE_BPS_READ].max = arg->bps_rd_max;
> + }
> + if (arg->has_bps_wr_max) {
> + cfg->buckets[THROTTLE_BPS_WRITE].max = arg->bps_wr_max;
> + }
> + if (arg->has_iops_max) {
> + cfg->buckets[THROTTLE_OPS_TOTAL].max = arg->iops_max;
> + }
> + if (arg->has_iops_rd_max) {
> + cfg->buckets[THROTTLE_OPS_READ].max = arg->iops_rd_max;
> + }
> + if (arg->has_iops_wr_max) {
> + cfg->buckets[THROTTLE_OPS_WRITE].max = arg->iops_wr_max;
> + }
> +
> + if (arg->has_bps_max_length) {
> + cfg->buckets[THROTTLE_BPS_TOTAL].burst_length = arg->bps_max_length;
> + }
> + if (arg->has_bps_rd_max_length) {
> + cfg->buckets[THROTTLE_BPS_READ].burst_length = arg->bps_rd_max_length;
> + }
> + if (arg->has_bps_wr_max_length) {
> + cfg->buckets[THROTTLE_BPS_WRITE].burst_length = arg->bps_wr_max_length;
> + }
> + if (arg->has_iops_max_length) {
> + cfg->buckets[THROTTLE_OPS_TOTAL].burst_length = arg->iops_max_length;
> + }
> + if (arg->has_iops_rd_max_length) {
> + cfg->buckets[THROTTLE_OPS_READ].burst_length = arg->iops_rd_max_length;
> + }
> + if (arg->has_iops_wr_max_length) {
> + cfg->buckets[THROTTLE_OPS_WRITE].burst_length = arg->iops_wr_max_length;
> + }
> +
> + if (arg->has_iops_size) {
> + cfg->op_size = arg->iops_size;
> + }
> +}
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2017-09-08 12:27 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-04 16:07 [Qemu-devel] [PATCH v10 0/6] fsdev: qmp interface for io throttling Pradeep Jagadeesh
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 1/6] throttle: factor out duplicate code Pradeep Jagadeesh
2017-09-06 9:49 ` Greg Kurz
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 2/6] qmp: Create IOThrottle structure Pradeep Jagadeesh
2017-09-08 9:37 ` Markus Armbruster
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 3/6] throttle: move out function to reuse the code Pradeep Jagadeesh
2017-09-08 12:27 ` Greg Kurz [this message]
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 4/6] hmp: create a throttle initialization function for code reusability Pradeep Jagadeesh
2017-09-05 12:03 ` Alberto Garcia
2017-09-08 12:31 ` Greg Kurz
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 5/6] fsdev: QMP interface for throttling Pradeep Jagadeesh
2017-09-08 10:02 ` Markus Armbruster
2017-09-08 11:33 ` Alberto Garcia
2017-09-08 12:51 ` Markus Armbruster
2017-09-08 12:19 ` Pradeep Jagadeesh
2017-09-08 12:34 ` Markus Armbruster
2017-09-08 12:49 ` Pradeep Jagadeesh
2017-09-11 9:23 ` Pradeep Jagadeesh
2017-09-04 16:07 ` [Qemu-devel] [PATCH v10 6/6] fsdev: hmp " Pradeep Jagadeesh
2017-09-05 7:53 ` Alberto Garcia
2017-09-05 8:28 ` Pradeep Jagadeesh
2017-09-05 8:57 ` Greg Kurz
2017-09-05 9:07 ` Alberto Garcia
2017-09-05 9:13 ` Pradeep Jagadeesh
2017-09-05 9:34 ` Alberto Garcia
2017-09-05 9:36 ` Pradeep Jagadeesh
2017-09-05 17:57 ` Dr. David Alan Gilbert
2017-09-05 21:19 ` [Qemu-devel] [PATCH v10 0/6] fsdev: qmp interface for io throttling Eric Blake
2017-09-06 10:12 ` Pradeep Jagadeesh
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=20170908142729.1008e033@bahia \
--to=groug@kaod.org \
--cc=armbru@redhat.com \
--cc=berto@igalia.com \
--cc=eblake@redhat.com \
--cc=jani.kokkonen@huawei.com \
--cc=pradeep.jagadeesh@huawei.com \
--cc=pradeepkiruvale@gmail.com \
--cc=qemu-devel@nongnu.org \
/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).