qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kurz <groug@kaod.org>
To: zhenwei pi <pizhenwei@bytedance.com>
Cc: <berto@igalia.com>, <kwolf@redhat.com>, <hreitz@redhat.com>,
	<qemu_oss@crudebyte.com>, <qemu-devel@nongnu.org>,
	<qemu-block@nongnu.org>
Subject: Re: [PATCH v5 8/9] fsdev: Use ThrottleDirection instread of bool is_write
Date: Mon, 7 Aug 2023 16:24:52 +0200	[thread overview]
Message-ID: <20230807162452.5160b645@bahia> (raw)
In-Reply-To: <20230728022006.1098509-9-pizhenwei@bytedance.com>

On Fri, 28 Jul 2023 10:20:05 +0800
zhenwei pi <pizhenwei@bytedance.com> wrote:

> 'bool is_write' style is obsolete from throttle framework, adapt
> fsdev to the new style.
> 
> Cc: Greg Kurz <groug@kaod.org>
> Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
> Signed-off-by: zhenwei pi <pizhenwei@bytedance.com>

Reviewed-by: Greg Kurz <groug@kaod.org>

> ---
>  fsdev/qemu-fsdev-throttle.c | 14 +++++++-------
>  fsdev/qemu-fsdev-throttle.h |  4 ++--
>  hw/9pfs/cofile.c            |  4 ++--
>  3 files changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/fsdev/qemu-fsdev-throttle.c b/fsdev/qemu-fsdev-throttle.c
> index 1c137d6f0f..d912da906d 100644
> --- a/fsdev/qemu-fsdev-throttle.c
> +++ b/fsdev/qemu-fsdev-throttle.c
> @@ -94,22 +94,22 @@ void fsdev_throttle_init(FsThrottle *fst)
>      }
>  }
>  
> -void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst, bool is_write,
> +void coroutine_fn fsdev_co_throttle_request(FsThrottle *fst,
> +                                            ThrottleDirection direction,
>                                              struct iovec *iov, int iovcnt)
>  {
> -    ThrottleDirection direction = is_write ? THROTTLE_WRITE : THROTTLE_READ;
> -
> +    assert(direction < THROTTLE_MAX);
>      if (throttle_enabled(&fst->cfg)) {
>          if (throttle_schedule_timer(&fst->ts, &fst->tt, direction) ||
> -            !qemu_co_queue_empty(&fst->throttled_reqs[is_write])) {
> -            qemu_co_queue_wait(&fst->throttled_reqs[is_write], NULL);
> +            !qemu_co_queue_empty(&fst->throttled_reqs[direction])) {
> +            qemu_co_queue_wait(&fst->throttled_reqs[direction], NULL);
>          }
>  
>          throttle_account(&fst->ts, direction, iov_size(iov, iovcnt));
>  
> -        if (!qemu_co_queue_empty(&fst->throttled_reqs[is_write]) &&
> +        if (!qemu_co_queue_empty(&fst->throttled_reqs[direction]) &&
>              !throttle_schedule_timer(&fst->ts, &fst->tt, direction)) {
> -            qemu_co_queue_next(&fst->throttled_reqs[is_write]);
> +            qemu_co_queue_next(&fst->throttled_reqs[direction]);
>          }
>      }
>  }
> diff --git a/fsdev/qemu-fsdev-throttle.h b/fsdev/qemu-fsdev-throttle.h
> index a21aecddc7..daa8ca2494 100644
> --- a/fsdev/qemu-fsdev-throttle.h
> +++ b/fsdev/qemu-fsdev-throttle.h
> @@ -23,14 +23,14 @@ typedef struct FsThrottle {
>      ThrottleState ts;
>      ThrottleTimers tt;
>      ThrottleConfig cfg;
> -    CoQueue      throttled_reqs[2];
> +    CoQueue      throttled_reqs[THROTTLE_MAX];
>  } FsThrottle;
>  
>  int fsdev_throttle_parse_opts(QemuOpts *, FsThrottle *, Error **);
>  
>  void fsdev_throttle_init(FsThrottle *);
>  
> -void coroutine_fn fsdev_co_throttle_request(FsThrottle *, bool ,
> +void coroutine_fn fsdev_co_throttle_request(FsThrottle *, ThrottleDirection ,
>                                              struct iovec *, int);
>  
>  void fsdev_throttle_cleanup(FsThrottle *);
> diff --git a/hw/9pfs/cofile.c b/hw/9pfs/cofile.c
> index 9c5344039e..71174c3e4a 100644
> --- a/hw/9pfs/cofile.c
> +++ b/hw/9pfs/cofile.c
> @@ -252,7 +252,7 @@ int coroutine_fn v9fs_co_pwritev(V9fsPDU *pdu, V9fsFidState *fidp,
>      if (v9fs_request_cancelled(pdu)) {
>          return -EINTR;
>      }
> -    fsdev_co_throttle_request(s->ctx.fst, true, iov, iovcnt);
> +    fsdev_co_throttle_request(s->ctx.fst, THROTTLE_WRITE, iov, iovcnt);
>      v9fs_co_run_in_worker(
>          {
>              err = s->ops->pwritev(&s->ctx, &fidp->fs, iov, iovcnt, offset);
> @@ -272,7 +272,7 @@ int coroutine_fn v9fs_co_preadv(V9fsPDU *pdu, V9fsFidState *fidp,
>      if (v9fs_request_cancelled(pdu)) {
>          return -EINTR;
>      }
> -    fsdev_co_throttle_request(s->ctx.fst, false, iov, iovcnt);
> +    fsdev_co_throttle_request(s->ctx.fst, THROTTLE_READ, iov, iovcnt);
>      v9fs_co_run_in_worker(
>          {
>              err = s->ops->preadv(&s->ctx, &fidp->fs, iov, iovcnt, offset);



-- 
Greg


  reply	other threads:[~2023-08-07 14:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-28  2:19 [PATCH v5 0/9] Misc fixes for throttle zhenwei pi
2023-07-28  2:19 ` [PATCH v5 1/9] throttle: introduce enum ThrottleDirection zhenwei pi
2023-07-28  2:19 ` [PATCH v5 2/9] test-throttle: use " zhenwei pi
2023-07-28  2:20 ` [PATCH v5 3/9] throttle: support read-only and write-only zhenwei pi
2023-07-28  2:20 ` [PATCH v5 4/9] test-throttle: test read only and write only zhenwei pi
2023-07-28  2:20 ` [PATCH v5 5/9] cryptodev: use NULL throttle timer cb for read direction zhenwei pi
2023-07-28  2:20 ` [PATCH v5 6/9] throttle: use enum ThrottleDirection instead of bool is_write zhenwei pi
2023-07-28  2:20 ` [PATCH v5 7/9] throttle: use THROTTLE_MAX/ARRAY_SIZE for hard code zhenwei pi
2023-07-28  2:20 ` [PATCH v5 8/9] fsdev: Use ThrottleDirection instread of bool is_write zhenwei pi
2023-08-07 14:24   ` Greg Kurz [this message]
2023-07-28  2:20 ` [PATCH v5 9/9] block/throttle-groups: " zhenwei pi
2023-07-28  9:47   ` Hanna Czenczek
2023-08-25 13:25 ` [PATCH v5 0/9] Misc fixes for throttle Hanna Czenczek

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=20230807162452.5160b645@bahia \
    --to=groug@kaod.org \
    --cc=berto@igalia.com \
    --cc=hreitz@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=pizhenwei@bytedance.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu_oss@crudebyte.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 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).