qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 720507: ratelimit: treat zero speed as unlimi


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 720507: ratelimit: treat zero speed as unlimited
Date: Mon, 28 Jun 2021 13:04:19 -0700

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 720507ed95023e45620f305767d12cd716e8b8ca
      
https://github.com/qemu/qemu/commit/720507ed95023e45620f305767d12cd716e8b8ca
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M include/qemu/ratelimit.h

  Log Message:
  -----------
  ratelimit: treat zero speed as unlimited

Both users of RateLimit, block-copy.c and blockjob.c, treat
a speed of zero as unlimited, while RateLimit treats it as
"as slow as possible".  The latter is nicer from the code
point of view but pretty useless, so disable rate limiting
if a speed of zero is provided.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-2-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: ca657c99e6b41fa765443fc93df5c4adf468e369
      
https://github.com/qemu/qemu/commit/ca657c99e6b41fa765443fc93df5c4adf468e369
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c

  Log Message:
  -----------
  block-copy: let ratelimit handle a speed of 0

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-3-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: c02b83ed1ff62211f4c44855e0ca1656d5811688
      
https://github.com/qemu/qemu/commit/c02b83ed1ff62211f4c44855e0ca1656d5811688
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M blockjob.c

  Log Message:
  -----------
  blockjob: let ratelimit handle a speed of 0

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-4-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: a7b4f8fc09ec62d09a11cce72a886c453636c547
      
https://github.com/qemu/qemu/commit/a7b4f8fc09ec62d09a11cce72a886c453636c547
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/meson.build
    A block/progress_meter.c
    M blockjob.c
    M include/qemu/progress_meter.h
    M job-qmp.c
    M job.c
    M qemu-img.c

  Log Message:
  -----------
  progressmeter: protect with a mutex

Progressmeter is protected by the AioContext mutex, which
is taken by the block jobs and their caller (like blockdev).

We would like to remove the dependency of block layer code on the
AioContext mutex, since most drivers and the core I/O code are already
not relying on it.

Create a new C file to implement the ProgressMeter API, but keep the
struct as public, to avoid forcing allocation on the heap.

Also add a mutex to be able to provide an accurate snapshot of the
progress values to the caller.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Message-Id: <20210614081130.22134-5-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: 55fa54a789f6e66fe9e7997429667e3e8917ffb9
      
https://github.com/qemu/qemu/commit/55fa54a789f6e66fe9e7997429667e3e8917ffb9
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M include/qemu/co-shared-resource.h
    M util/qemu-co-shared-resource.c

  Log Message:
  -----------
  co-shared-resource: protect with a mutex

co-shared-resource is currently not thread-safe, as also reported
in co-shared-resource.h. Add a QemuMutex because co_try_get_from_shres
can also be invoked from non-coroutine context.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210614081130.22134-6-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: c6a3e3df3011288c2395cd5755547c91e943b10a
      
https://github.com/qemu/qemu/commit/c6a3e3df3011288c2395cd5755547c91e943b10a
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c

  Log Message:
  -----------
  block-copy: small refactor in block_copy_task_entry and block_copy_common

Use a local variable instead of referencing BlockCopyState through a
BlockCopyCallState or BlockCopyTask every time.
This is in preparation for next patches.

No functional change intended.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210624072043.180494-2-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: 05d5e12b243df43a8a58568edf6a342806879d98
      
https://github.com/qemu/qemu/commit/05d5e12b243df43a8a58568edf6a342806879d98
  Author: Paolo Bonzini <pbonzini@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c

  Log Message:
  -----------
  block-copy: streamline choice of copy_range vs. read/write

Put the logic to determine the copy size in a separate function, so
that there is a simple state machine for the possible methods of
copying data from one BlockDriverState to the other.

Use .method instead of .copy_range as in-out argument, and
include also .zeroes as an additional copy method.

While at it, store the common computation of block_copy_max_transfer
into a new field of BlockCopyState, and make sure that we always
obey max_transfer; that's more efficient even for the
COPY_RANGE_READ_WRITE case.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210624072043.180494-3-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: e3dd339feec2da3bcd82021e4ce4fe09dbf9c8b4
      
https://github.com/qemu/qemu/commit/e3dd339feec2da3bcd82021e4ce4fe09dbf9c8b4
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c

  Log Message:
  -----------
  block-copy: move progress_set_remaining in block_copy_task_end

Moving this function in task_end ensures to update the progress
anyways, even if there is an error.

It also helps in next patch, allowing task_end to have only
one critical section.

Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210624072043.180494-4-eesposit@redhat.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: d0c389d2ce6031d80e872e8e1b6ebb0f96afbe69
      
https://github.com/qemu/qemu/commit/d0c389d2ce6031d80e872e8e1b6ebb0f96afbe69
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c

  Log Message:
  -----------
  block-copy: add CoMutex lock

Group various structures fields, to better understand what we need to
protect with a lock and what doesn't need it.
Then, add a CoMutex to protect concurrent access of block-copy
data structures. This mutex also protects .copy_bitmap, because its thread-safe
API does not prevent it from assigning two tasks to the same
bitmap region.

Exceptions to the lock:
- .sleep_state is handled in the series "coroutine: new sleep/wake API"
and thus here left as TODO.

- .finished, .cancelled and reads to .ret and .error_is_read will be
protected in the following patch, because are used also outside
coroutines.

- .skip_unallocated is atomic. Including it under the mutex would
increase the critical sections and make them also much more complex.
We can have it as atomic since it is only written from outside and
read by block-copy coroutines.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210624072043.180494-5-eesposit@redhat.com>
  [vsementsov: fix typo in comment]
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: 149009bef4b4b4db37b3cf72b41dc2c6e8ca1885
      
https://github.com/qemu/qemu/commit/149009bef4b4b4db37b3cf72b41dc2c6e8ca1885
  Author: Emanuele Giuseppe Esposito <eesposit@redhat.com>
  Date:   2021-06-25 (Fri, 25 Jun 2021)

  Changed paths:
    M block/block-copy.c
    M include/block/block-copy.h

  Log Message:
  -----------
  block-copy: atomic .cancelled and .finished fields in BlockCopyCallState

By adding acquire/release pairs, we ensure that .ret and .error_is_read
fields are written by block_copy_dirty_clusters before .finished is true,
and that they are read by API user after .finished is true.

The atomic here are necessary because the fields are concurrently modified
in coroutines, and read outside.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
Message-Id: <20210624072043.180494-6-eesposit@redhat.com>
Reviewed-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>


  Commit: 9e654e10197f5a014eccd71de5ea633c1b0f4303
      
https://github.com/qemu/qemu/commit/9e654e10197f5a014eccd71de5ea633c1b0f4303
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2021-06-28 (Mon, 28 Jun 2021)

  Changed paths:
    M block/block-copy.c
    M block/meson.build
    A block/progress_meter.c
    M blockjob.c
    M include/block/block-copy.h
    M include/qemu/co-shared-resource.h
    M include/qemu/progress_meter.h
    M include/qemu/ratelimit.h
    M job-qmp.c
    M job.c
    M qemu-img.c
    M util/qemu-co-shared-resource.c

  Log Message:
  -----------
  Merge remote-tracking branch 'remotes/vsementsov/tags/pull-jobs-2021-06-25' 
into staging

block: Make block-copy API thread-safe

# gpg: Signature made Fri 25 Jun 2021 13:40:24 BST
# gpg:                using RSA key 8B9C26CDB2FD147C880E86A1561F24C1F19F79FB
# gpg: Good signature from "Vladimir Sementsov-Ogievskiy 
<vsementsov@virtuozzo.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 8B9C 26CD B2FD 147C 880E  86A1 561F 24C1 F19F 79FB

* remotes/vsementsov/tags/pull-jobs-2021-06-25:
  block-copy: atomic .cancelled and .finished fields in BlockCopyCallState
  block-copy: add CoMutex lock
  block-copy: move progress_set_remaining in block_copy_task_end
  block-copy: streamline choice of copy_range vs. read/write
  block-copy: small refactor in block_copy_task_entry and block_copy_common
  co-shared-resource: protect with a mutex
  progressmeter: protect with a mutex
  blockjob: let ratelimit handle a speed of 0
  block-copy: let ratelimit handle a speed of 0
  ratelimit: treat zero speed as unlimited

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/271fc190b309...9e654e10197f



reply via email to

[Prev in Thread] Current Thread [Next in Thread]