[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 5/6] block/block-copy: add memory limit
From: |
Max Reitz |
Subject: |
Re: [PATCH 5/6] block/block-copy: add memory limit |
Date: |
Mon, 7 Oct 2019 17:27:12 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0 |
On 03.10.19 19:15, Vladimir Sementsov-Ogievskiy wrote:
> Currently total allocation for parallel requests to block-copy instance
> is unlimited. Let's limit it to 128 MiB.
>
> For now block-copy is used only in backup, so actually we limit total
> allocation for backup job.
>
> Signed-off-by: Vladimir Sementsov-Ogievskiy <address@hidden>
> ---
> include/block/block-copy.h | 3 +++
> block/block-copy.c | 5 +++++
> 2 files changed, 8 insertions(+)
>
> diff --git a/include/block/block-copy.h b/include/block/block-copy.h
> index e2e135ff1b..bb666e7068 100644
> --- a/include/block/block-copy.h
> +++ b/include/block/block-copy.h
> @@ -16,6 +16,7 @@
> #define BLOCK_COPY_H
>
> #include "block/block.h"
> +#include "qemu/co-shared-amount.h"
>
> typedef struct BlockCopyInFlightReq {
> int64_t start_byte;
> @@ -69,6 +70,8 @@ typedef struct BlockCopyState {
> */
> ProgressResetCallbackFunc progress_reset_callback;
> void *progress_opaque;
> +
> + QemuCoSharedAmount *mem;
> } BlockCopyState;
>
> BlockCopyState *block_copy_state_new(BdrvChild *source, BdrvChild *target,
> diff --git a/block/block-copy.c b/block/block-copy.c
> index cc49d2345d..e700c20d0f 100644
> --- a/block/block-copy.c
> +++ b/block/block-copy.c
> @@ -21,6 +21,7 @@
> #include "qemu/units.h"
>
> #define BLOCK_COPY_MAX_COPY_RANGE (16 * MiB)
> +#define BLOCK_COPY_MAX_MEM (128 * MiB)
>
> static void coroutine_fn block_copy_wait_inflight_reqs(BlockCopyState *s,
> int64_t start,
> @@ -64,6 +65,7 @@ void block_copy_state_free(BlockCopyState *s)
> }
>
> bdrv_release_dirty_bitmap(s->source->bs, s->copy_bitmap);
> + qemu_co_shared_amount_free(s->mem);
> g_free(s);
> }
>
> @@ -95,6 +97,7 @@ BlockCopyState *block_copy_state_new(BdrvChild *source,
> BdrvChild *target,
> .cluster_size = cluster_size,
> .len = bdrv_dirty_bitmap_size(copy_bitmap),
> .write_flags = write_flags,
> + .mem = qemu_co_shared_amount_new(BLOCK_COPY_MAX_MEM),
> };
>
> s->copy_range_size = QEMU_ALIGN_DOWN(max_transfer, cluster_size),
> @@ -316,7 +319,9 @@ int coroutine_fn block_copy(BlockCopyState *s,
>
> bdrv_reset_dirty_bitmap(s->copy_bitmap, start, chunk_end - start);
>
> + qemu_co_get_amount(s->mem, chunk_end - start);
Now that I see it like this, maybe the name is too short. This sounds
like it was trying to get some amount of coroutines.
Would “qemu_co_get_from_shared_amount” be too long? (Something like
qemu_co_sham_alloc() would be funny, but maybe not. :-) Or maybe
exactly because it”s funny.)
Max
> ret = block_copy_do_copy(s, start, chunk_end, error_is_read);
> + qemu_co_put_amount(s->mem, chunk_end - start);
> if (ret < 0) {
> bdrv_set_dirty_bitmap(s->copy_bitmap, start, chunk_end - start);
> break;
>
signature.asc
Description: OpenPGP digital signature
- Re: [PATCH 4/6] util: introduce co-shared-amount, (continued)
- [PATCH 2/6] block/block-copy: limit copy_range_size to 16 MiB, Vladimir Sementsov-Ogievskiy, 2019/10/03
- [PATCH 3/6] block/block-copy: refactor copying, Vladimir Sementsov-Ogievskiy, 2019/10/03
- [PATCH 1/6] block/block-copy: allocate buffer in block_copy_with_bounce_buffer, Vladimir Sementsov-Ogievskiy, 2019/10/03
- [PATCH 5/6] block/block-copy: add memory limit, Vladimir Sementsov-Ogievskiy, 2019/10/03
- Re: [PATCH 5/6] block/block-copy: add memory limit,
Max Reitz <=
- Re: [PATCH 5/6] block/block-copy: add memory limit, Vladimir Sementsov-Ogievskiy, 2019/10/07
- Re: [PATCH 5/6] block/block-copy: add memory limit, Max Reitz, 2019/10/08
- Re: [PATCH 5/6] block/block-copy: add memory limit, Vladimir Sementsov-Ogievskiy, 2019/10/08
- Re: [PATCH 5/6] block/block-copy: add memory limit, Vladimir Sementsov-Ogievskiy, 2019/10/08
- Re: [PATCH 5/6] block/block-copy: add memory limit, Max Reitz, 2019/10/08
- Re: [PATCH 5/6] block/block-copy: add memory limit, Max Reitz, 2019/10/08