[Qemu-devel] [PATCH] vpc: unlock Coroutine lock to make IO submit Concurrently

Zhengui li posted 1 patch 5 years, 1 month ago
Test asan passed
Test docker-clang@ubuntu passed
Test docker-mingw@fedora passed
Test checkpatch passed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1552658678-7816-1-git-send-email-lizhengui@huawei.com
Maintainers: Kevin Wolf <kwolf@redhat.com>, Max Reitz <mreitz@redhat.com>
block/vpc.c | 4 ++++
1 file changed, 4 insertions(+)
[Qemu-devel] [PATCH] vpc: unlock Coroutine lock to make IO submit Concurrently
Posted by Zhengui li 5 years, 1 month ago
Concurrent IO becomes serial IO because of the qemu Coroutine lock,
which reduce IO performance severely.

So unlock Coroutine lock before bdrv_co_pwritev and
bdrv_co_preadv to fix it.

Signed-off-by: Zhengui li <lizhengui@huawei.com>
---
 block/vpc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/block/vpc.c b/block/vpc.c
index 52ab717..1133855 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -639,8 +639,10 @@ vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
             qemu_iovec_reset(&local_qiov);
             qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
 
+            qemu_co_mutex_unlock(&s->lock);
             ret = bdrv_co_preadv(bs->file, image_offset, n_bytes,
                                  &local_qiov, 0);
+            qemu_co_mutex_lock(&s->lock);
             if (ret < 0) {
                 goto fail;
             }
@@ -697,8 +699,10 @@ vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
         qemu_iovec_reset(&local_qiov);
         qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
 
+        qemu_co_mutex_unlock(&s->lock);
         ret = bdrv_co_pwritev(bs->file, image_offset, n_bytes,
                               &local_qiov, 0);
+        qemu_co_mutex_lock(&s->lock);
         if (ret < 0) {
             goto fail;
         }
-- 
2.7.2.windows.1



Re: [Qemu-devel] [PATCH] vpc: unlock Coroutine lock to make IO submit Concurrently
Posted by Paolo Bonzini 5 years, 1 month ago
On 15/03/19 15:04, Zhengui li wrote:
> Concurrent IO becomes serial IO because of the qemu Coroutine lock,
> which reduce IO performance severely.
> 
> So unlock Coroutine lock before bdrv_co_pwritev and
> bdrv_co_preadv to fix it.
> 
> Signed-off-by: Zhengui li <lizhengui@huawei.com>
> ---
>  block/vpc.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/block/vpc.c b/block/vpc.c
> index 52ab717..1133855 100644
> --- a/block/vpc.c
> +++ b/block/vpc.c
> @@ -639,8 +639,10 @@ vpc_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
>              qemu_iovec_reset(&local_qiov);
>              qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
>  
> +            qemu_co_mutex_unlock(&s->lock);
>              ret = bdrv_co_preadv(bs->file, image_offset, n_bytes,
>                                   &local_qiov, 0);
> +            qemu_co_mutex_lock(&s->lock);
>              if (ret < 0) {
>                  goto fail;
>              }
> @@ -697,8 +699,10 @@ vpc_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
>          qemu_iovec_reset(&local_qiov);
>          qemu_iovec_concat(&local_qiov, qiov, bytes_done, n_bytes);
>  
> +        qemu_co_mutex_unlock(&s->lock);
>          ret = bdrv_co_pwritev(bs->file, image_offset, n_bytes,
>                                &local_qiov, 0);
> +        qemu_co_mutex_lock(&s->lock);
>          if (ret < 0) {
>              goto fail;
>          }
> 

This should be okay, because vpc.c is somewhat simple-minded and it
doesn't recycle unused blocks in the middle of the file.

Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>

Paolo

Re: [Qemu-devel] [Qemu-block] [PATCH] vpc: unlock Coroutine lock to make IO submit Concurrently
Posted by Kevin Wolf 5 years, 1 month ago
Am 15.03.2019 um 15:04 hat Zhengui li geschrieben:
> Concurrent IO becomes serial IO because of the qemu Coroutine lock,
> which reduce IO performance severely.
> 
> So unlock Coroutine lock before bdrv_co_pwritev and
> bdrv_co_preadv to fix it.
> 
> Signed-off-by: Zhengui li <lizhengui@huawei.com>

Thanks, applied to the block-next branch for 4.1.

Kevin