All of lore.kernel.org
 help / color / mirror / Atom feed
From: xiezhide <xiezhide@huawei.com>
To: Greg Kurz <groug@kaod.org>
Cc: "qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
	"aneesh.kumar@linux.vnet.ibm.com"
	<aneesh.kumar@linux.vnet.ibm.com>,
	"eblake@redhat.com" <eblake@redhat.com>,
	"armbru@redhat.com" <armbru@redhat.com>,
	"berto@igalia.com" <berto@igalia.com>,
	zengcanfu 00215970 <zengcanfu@huawei.com>,
	Jinxuefeng <jinxuefeng@huawei.com>,
	"Chenhui (Felix, Euler)" <chenhui.rtos@huawei.com>,
	Pradeep Jagadeesh <pradeep.jagadeesh@huawei.com>
Subject: Re: [Qemu-devel] [PATCH v5 1/6] fsdev-throttle-qmp: factor out throttle code to reuse code
Date: Fri, 23 Nov 2018 06:42:36 +0000	[thread overview]
Message-ID: <A02D6AA901860840B46E751C5E9E38B43CC99B38@dggeml512-mbx.china.huawei.com> (raw)
In-Reply-To: <20181122154610.50150df4@bahia.lan>



> -----Original Message-----
> From: Greg Kurz [mailto:groug@kaod.org]
> Sent: Thursday, November 22, 2018 10:46 PM
> To: xiezhide <xiezhide@huawei.com>
> Cc: qemu-devel@nongnu.org; aneesh.kumar@linux.vnet.ibm.com;
> eblake@redhat.com; armbru@redhat.com; berto@igalia.com; zengcanfu
> 00215970 <zengcanfu@huawei.com>; Jinxuefeng <jinxuefeng@huawei.com>;
> Chenhui (Felix, Euler) <chenhui.rtos@huawei.com>
> Subject: Re: [PATCH v5 1/6] fsdev-throttle-qmp: factor out throttle code to
> reuse code
> 
> On Fri, 16 Nov 2018 15:59:16 +0800
> xiezhide <xiezhide@huawei.com> wrote:
> 
> > Factor out throttle parameter parsing code to a new common function
> > which will be used by block and fsdev.
> > Rename function throttle_parse_options to throttle_parse_group to
> > resolve function name conflict
> >
> > Reviewed-by: Eric Blake <eblake@redhat.com>
> > Signed-off-by: xiezhide <xiezhide@huawei.com>
> > ---
> 
> Reviewed-by: Greg Kurz <groug@kaod.org>
> 
> And, since I guess this will likely go through someone else's tree, for the fsdev
> changes:

Yes,Pradeep Jagadeesh<pradeep.jagadeesh@huawei.com> had done some work for this, and I take it over now

> 
> Acked-by: Greg Kurz <groug@kaod.org>
> 
> >  block/throttle.c                |  6 ++--
> >  blockdev.c                      | 43 +-------------------------
> >  fsdev/qemu-fsdev-throttle.c     | 44 ++------------------------
> >  include/qemu/throttle-options.h |  2 ++
> >  include/qemu/throttle.h         |  4 +--
> >  include/qemu/typedefs.h         |  1 +
> >  util/throttle.c                 | 68
> +++++++++++++++++++++++++++++++++++++++++
> >  7 files changed, 79 insertions(+), 89 deletions(-)
> >
> > diff --git a/block/throttle.c b/block/throttle.c index
> > 636c976..bd23c58 100644
> > --- a/block/throttle.c
> > +++ b/block/throttle.c
> > @@ -41,7 +41,7 @@ static QemuOptsList throttle_opts = {
> >   * @group and must be freed by the caller.
> >   * If there's an error then @group remains unmodified.
> >   */
> > -static int throttle_parse_options(QDict *options, char **group, Error
> > **errp)
> > +static int throttle_parse_group(QDict *options, char **group, Error
> > +**errp)
> >  {
> >      int ret;
> >      const char *group_name;
> > @@ -90,7 +90,7 @@ static int throttle_open(BlockDriverState *bs, QDict
> *options,
> >      bs->supported_zero_flags = bs->file->bs->supported_zero_flags |
> >                                 BDRV_REQ_WRITE_UNCHANGED;
> >
> > -    ret = throttle_parse_options(options, &group, errp);
> > +    ret = throttle_parse_group(options, &group, errp);
> >      if (ret == 0) {
> >          /* Register membership to group with name group_name */
> >          throttle_group_register_tgm(tgm, group,
> > bdrv_get_aio_context(bs)); @@ -179,7 +179,7 @@ static int
> throttle_reopen_prepare(BDRVReopenState *reopen_state,
> >      assert(reopen_state != NULL);
> >      assert(reopen_state->bs != NULL);
> >
> > -    ret = throttle_parse_options(reopen_state->options, &group, errp);
> > +    ret = throttle_parse_group(reopen_state->options, &group, errp);
> >      reopen_state->opaque = group;
> >      return ret;
> >  }
> > diff --git a/blockdev.c b/blockdev.c
> > index 81f95d9..fce5d8f 100644
> > --- a/blockdev.c
> > +++ b/blockdev.c
> > @@ -400,48 +400,7 @@ static void
> extract_common_blockdev_options(QemuOpts *opts, int *bdrv_flags,
> >      }
> >
> >      if (throttle_cfg) {
> > -        throttle_config_init(throttle_cfg);
> > -        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
> > -            qemu_opt_get_number(opts, "throttling.bps-total", 0);
> > -        throttle_cfg->buckets[THROTTLE_BPS_READ].avg  =
> > -            qemu_opt_get_number(opts, "throttling.bps-read", 0);
> > -        throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =
> > -            qemu_opt_get_number(opts, "throttling.bps-write", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =
> > -            qemu_opt_get_number(opts, "throttling.iops-total", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_READ].avg =
> > -            qemu_opt_get_number(opts, "throttling.iops-read", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =
> > -            qemu_opt_get_number(opts, "throttling.iops-write", 0);
> > -
> > -        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =
> > -            qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
> > -        throttle_cfg->buckets[THROTTLE_BPS_READ].max  =
> > -            qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
> > -        throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =
> > -            qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =
> > -            qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_READ].max =
> > -            qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
> > -        throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =
> > -            qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
> > -
> > -        throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =
> > -            qemu_opt_get_number(opts,
> "throttling.bps-total-max-length", 1);
> > -        throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length  =
> > -            qemu_opt_get_number(opts,
> "throttling.bps-read-max-length", 1);
> > -        throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =
> > -            qemu_opt_get_number(opts,
> "throttling.bps-write-max-length", 1);
> > -        throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =
> > -            qemu_opt_get_number(opts,
> "throttling.iops-total-max-length", 1);
> > -        throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =
> > -            qemu_opt_get_number(opts,
> "throttling.iops-read-max-length", 1);
> > -        throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =
> > -            qemu_opt_get_number(opts,
> "throttling.iops-write-max-length", 1);
> > -
> > -        throttle_cfg->op_size =
> > -            qemu_opt_get_number(opts, "throttling.iops-size", 0);
> > +        throttle_parse_options(throttle_cfg, opts);
> >
> >          if (!throttle_is_valid(throttle_cfg, errp)) {
> >              return;
> > diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
> > index cfd8641..6a4108a 100644
> > --- a/fsdev/qemu-fsdev-throttle.c
> > +++ b/fsdev/qemu-fsdev-throttle.c
> > @@ -17,6 +17,7 @@
> >  #include "qemu-fsdev-throttle.h"
> >  #include "qemu/iov.h"
> >  #include "qemu/option.h"
> > +#include "qemu/throttle-options.h"
> >
> >  static void fsdev_throttle_read_timer_cb(void *opaque)  { @@ -32,48
> > +33,7 @@ static void fsdev_throttle_write_timer_cb(void *opaque)
> >
> >  void fsdev_throttle_parse_opts(QemuOpts *opts, FsThrottle *fst, Error
> > **errp)  {
> > -    throttle_config_init(&fst->cfg);
> > -    fst->cfg.buckets[THROTTLE_BPS_TOTAL].avg =
> > -        qemu_opt_get_number(opts, "throttling.bps-total", 0);
> > -    fst->cfg.buckets[THROTTLE_BPS_READ].avg  =
> > -        qemu_opt_get_number(opts, "throttling.bps-read", 0);
> > -    fst->cfg.buckets[THROTTLE_BPS_WRITE].avg =
> > -        qemu_opt_get_number(opts, "throttling.bps-write", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_TOTAL].avg =
> > -        qemu_opt_get_number(opts, "throttling.iops-total", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_READ].avg =
> > -        qemu_opt_get_number(opts, "throttling.iops-read", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_WRITE].avg =
> > -        qemu_opt_get_number(opts, "throttling.iops-write", 0);
> > -
> > -    fst->cfg.buckets[THROTTLE_BPS_TOTAL].max =
> > -        qemu_opt_get_number(opts, "throttling.bps-total-max", 0);
> > -    fst->cfg.buckets[THROTTLE_BPS_READ].max  =
> > -        qemu_opt_get_number(opts, "throttling.bps-read-max", 0);
> > -    fst->cfg.buckets[THROTTLE_BPS_WRITE].max =
> > -        qemu_opt_get_number(opts, "throttling.bps-write-max", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_TOTAL].max =
> > -        qemu_opt_get_number(opts, "throttling.iops-total-max", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_READ].max =
> > -        qemu_opt_get_number(opts, "throttling.iops-read-max", 0);
> > -    fst->cfg.buckets[THROTTLE_OPS_WRITE].max =
> > -        qemu_opt_get_number(opts, "throttling.iops-write-max", 0);
> > -
> > -    fst->cfg.buckets[THROTTLE_BPS_TOTAL].burst_length =
> > -        qemu_opt_get_number(opts, "throttling.bps-total-max-length",
> 1);
> > -    fst->cfg.buckets[THROTTLE_BPS_READ].burst_length  =
> > -        qemu_opt_get_number(opts, "throttling.bps-read-max-length",
> 1);
> > -    fst->cfg.buckets[THROTTLE_BPS_WRITE].burst_length =
> > -        qemu_opt_get_number(opts, "throttling.bps-write-max-length",
> 1);
> > -    fst->cfg.buckets[THROTTLE_OPS_TOTAL].burst_length =
> > -        qemu_opt_get_number(opts, "throttling.iops-total-max-length",
> 1);
> > -    fst->cfg.buckets[THROTTLE_OPS_READ].burst_length =
> > -        qemu_opt_get_number(opts, "throttling.iops-read-max-length",
> 1);
> > -    fst->cfg.buckets[THROTTLE_OPS_WRITE].burst_length =
> > -        qemu_opt_get_number(opts, "throttling.iops-write-max-length",
> 1);
> > -    fst->cfg.op_size =
> > -        qemu_opt_get_number(opts, "throttling.iops-size", 0);
> > -
> > +    throttle_parse_options(&fst->cfg, opts);
> >      throttle_is_valid(&fst->cfg, errp);  }
> >
> > diff --git a/include/qemu/throttle-options.h
> > b/include/qemu/throttle-options.h index 3528a8f..944a08c 100644
> > --- a/include/qemu/throttle-options.h
> > +++ b/include/qemu/throttle-options.h
> > @@ -111,4 +111,6 @@
> >              .help = "when limiting by iops max size of an I/O in bytes",\
> >          }
> >
> > +void throttle_parse_options(ThrottleConfig *, QemuOpts *);
> > +
> >  #endif
> > diff --git a/include/qemu/throttle.h b/include/qemu/throttle.h index
> > abeb886..f379d91 100644
> > --- a/include/qemu/throttle.h
> > +++ b/include/qemu/throttle.h
> > @@ -90,10 +90,10 @@ typedef struct LeakyBucket {
> >   * However it allows to keep the code clean and the bucket field is reset to
> >   * zero at the right time.
> >   */
> > -typedef struct ThrottleConfig {
> > +struct ThrottleConfig {
> >      LeakyBucket buckets[BUCKETS_COUNT]; /* leaky buckets */
> >      uint64_t op_size;         /* size of an operation in bytes */
> > -} ThrottleConfig;
> > +};
> >
> >  typedef struct ThrottleState {
> >      ThrottleConfig cfg;       /* configuration */
> > diff --git a/include/qemu/typedefs.h b/include/qemu/typedefs.h index
> > 3ec0e13..0d75edc 100644
> > --- a/include/qemu/typedefs.h
> > +++ b/include/qemu/typedefs.h
> > @@ -109,6 +109,7 @@ typedef struct SerialState SerialState;  typedef
> > struct SHPCDevice SHPCDevice;  typedef struct SMBusDevice SMBusDevice;
> > typedef struct SSIBus SSIBus;
> > +typedef struct ThrottleConfig ThrottleConfig;
> >  typedef struct uWireSlave uWireSlave;  typedef struct VirtIODevice
> > VirtIODevice;  typedef struct Visitor Visitor; diff --git
> > a/util/throttle.c b/util/throttle.c index b38e742..e7db2ad 100644
> > --- a/util/throttle.c
> > +++ b/util/throttle.c
> > @@ -27,6 +27,8 @@
> >  #include "qemu/throttle.h"
> >  #include "qemu/timer.h"
> >  #include "block/aio.h"
> > +#include "qemu/option.h"
> > +#include "qemu/throttle-options.h"
> >
> >  /* This function make a bucket leak
> >   *
> > @@ -636,3 +638,69 @@ void throttle_config_to_limits(ThrottleConfig *cfg,
> ThrottleLimits *var)
> >      var->has_iops_write_max_length = true;
> >      var->has_iops_size = true;
> >  }
> > +
> > +/* parse the throttle options
> > + *
> > + * @opts: qemu options
> > + * @throttle_cfg: throttle configuration  */ void
> > +throttle_parse_options(ThrottleConfig *throttle_cfg, QemuOpts *opts)
> > +{
> > +    throttle_config_init(throttle_cfg);
> > +    throttle_cfg->buckets[THROTTLE_BPS_TOTAL].avg =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_TOTAL, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_READ].avg  =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_READ, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_WRITE].avg =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_WRITE, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_TOTAL].avg =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_TOTAL, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_READ].avg =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_READ, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_WRITE].avg =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_WRITE, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_TOTAL].max =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_TOTAL_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_READ].max  =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_READ_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_WRITE].max =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_WRITE_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_TOTAL].max =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_TOTAL_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_READ].max =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_READ_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_OPS_WRITE].max =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_WRITE_MAX, 0);
> > +    throttle_cfg->buckets[THROTTLE_BPS_TOTAL].burst_length =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_TOTAL_MAX_LENGTH,
> 1);
> > +    throttle_cfg->buckets[THROTTLE_BPS_READ].burst_length  =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_READ_MAX_LENGTH,
> 1);
> > +    throttle_cfg->buckets[THROTTLE_BPS_WRITE].burst_length =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_BPS_WRITE_MAX_LENGTH,
> 1);
> > +    throttle_cfg->buckets[THROTTLE_OPS_TOTAL].burst_length =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_TOTAL_MAX_LENGTH,
> 1);
> > +    throttle_cfg->buckets[THROTTLE_OPS_READ].burst_length =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_READ_MAX_LENGTH,
> 1);
> > +    throttle_cfg->buckets[THROTTLE_OPS_WRITE].burst_length =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +                            QEMU_OPT_IOPS_WRITE_MAX_LENGTH,
> 1);
> > +    throttle_cfg->op_size =
> > +        qemu_opt_get_number(opts, THROTTLE_OPT_PREFIX
> > +QEMU_OPT_IOPS_SIZE, 0); }


  reply	other threads:[~2018-11-23  6:43 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-16  7:58 [Qemu-devel] [PATCH v5 0/6] fsdev-throttle-qmp: qmp interface for fsdev io throttling xiezhide
2018-11-16  7:59 ` [Qemu-devel] [PATCH v5 1/6] fsdev-throttle-qmp: factor out throttle code to reuse code xiezhide
2018-11-22 14:46   ` Greg Kurz
2018-11-23  6:42     ` xiezhide [this message]
2018-11-16  7:59 ` [Qemu-devel] [PATCH v5 2/6] fsdev-throttle-qmp: Rename the ThrottleLimits member names xiezhide
2018-11-28  9:25   ` Markus Armbruster
2018-11-28 13:09     ` Eric Blake
2018-11-29  7:23       ` xiezhide
2018-11-29  8:59       ` Markus Armbruster
2018-11-30  1:39         ` xiezhide
2018-11-29  7:10     ` xiezhide
2018-11-16  7:59 ` [Qemu-devel] [PATCH v5 3/6] fsdev-throttle-qmp: Rewrite BlockIOThrottle with ThrottleLimits as its base class xiezhide
2018-11-16  8:00 ` [Qemu-devel] [PATCH v5 4/6] fsdev-throttle-qmp: Move ThrottleLimits into a new file for future reuse xiezhide
2018-11-16  8:00 ` [Qemu-devel] [PATCH v5 5/6] fsdev-throttle-qmp: qmp interface for fsdev io throttling xiezhide
2018-11-16  8:00 ` [Qemu-devel] [PATCH v5 6/6] fsdev-throttle-qmp: hmp " xiezhide

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=A02D6AA901860840B46E751C5E9E38B43CC99B38@dggeml512-mbx.china.huawei.com \
    --to=xiezhide@huawei.com \
    --cc=aneesh.kumar@linux.vnet.ibm.com \
    --cc=armbru@redhat.com \
    --cc=berto@igalia.com \
    --cc=chenhui.rtos@huawei.com \
    --cc=eblake@redhat.com \
    --cc=groug@kaod.org \
    --cc=jinxuefeng@huawei.com \
    --cc=pradeep.jagadeesh@huawei.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zengcanfu@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.