From: Max Reitz <mreitz@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>
Cc: "kwolf@redhat.com" <kwolf@redhat.com>,
"jsnow@redhat.com" <jsnow@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
Denis Lunev <den@virtuozzo.com>
Subject: Re: [PATCH 5/6] block/block-copy: add memory limit
Date: Tue, 8 Oct 2019 11:56:32 +0200 [thread overview]
Message-ID: <73390228-76f4-1bc2-3a6f-a99f1422a6d6@redhat.com> (raw)
In-Reply-To: <c6cfb56c-970d-ab44-ee93-639c65370dc2@virtuozzo.com>
[-- Attachment #1.1: Type: text/plain, Size: 4779 bytes --]
On 08.10.19 11:15, Vladimir Sementsov-Ogievskiy wrote:
> 08.10.2019 12:03, Max Reitz wrote:
>> On 07.10.19 19:10, Vladimir Sementsov-Ogievskiy wrote:
>>> 07.10.2019 18:27, Max Reitz wrote:
>>>> 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 <vsementsov@virtuozzo.com>
>>>>> ---
>>>>> 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.)
>>>>
>>>
>>> hmm sham may be interpreted as shared memory, not only like shame..
>>
>> “sham” is also a word by itself. :-)
>
> Hmm didn't know, me go to google translate. OK, sham looks a lot nicer than shame)
>
>>
>>> And if we call it _alloc, the opposite should be _free, but how to
>>> distinguish it from freeing the whole object? Hmm, use create/destroy for
>>> the whole object maybe.
>>>
>>> May be, drop "qemu_" ? It's not very informative. Or may be drop "co_"?.
>>>
>>> I don't like shaming my shared amount :)
>>
>> It’s worse calling it all a sham.
>>
>>> May be, we should imagine, what are we allocating? May be balls?
>>>
>>> struct BallAllocator
>>>
>>> ball_allocator_create
>>> ball_allocator_destroy
>>>
>>> co_try_alloc_balls
>>> co_alloc_balls
>>> co_free_balls
>>>
>>> Or bars? Or which thing may be used for funny naming and to not intersect
>>> with existing concepts like memory?
>>
>> I love it (thanks for making my morning), but I fear it may be
>> interpreted as risqué.
>>
>> Maybe just shres for shared resource? So alloc_from_shres?
>>
>
> OK for me. But.. How to name _free function than?
>
> struct SharedResource
>
> shres_create
> shres_destroy
>
> co_try_alloc_from_shres
> co_alloc_from_shres
> co_free_???
>
> co_free_res_alloced_from_shres ? :)
>
> or
>
> co_try_get_from_shres
> co_get_from_shres
> co_put_to_shres
Sounds good to me.
Max
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2019-10-08 9:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-03 17:15 [PATCH 0/6] block-copy: memory limit Vladimir Sementsov-Ogievskiy
2019-10-03 17:15 ` [PATCH 1/6] block/block-copy: allocate buffer in block_copy_with_bounce_buffer Vladimir Sementsov-Ogievskiy
2019-10-07 13:30 ` Max Reitz
2019-10-03 17:15 ` [PATCH 2/6] block/block-copy: limit copy_range_size to 16 MiB Vladimir Sementsov-Ogievskiy
2019-10-07 13:40 ` Max Reitz
2019-10-03 17:15 ` [PATCH 3/6] block/block-copy: refactor copying Vladimir Sementsov-Ogievskiy
2019-10-07 14:17 ` Max Reitz
2019-10-07 16:29 ` Vladimir Sementsov-Ogievskiy
2019-10-03 17:15 ` [PATCH 4/6] util: introduce co-shared-amount Vladimir Sementsov-Ogievskiy
2019-10-07 15:22 ` Max Reitz
2019-10-07 16:49 ` Vladimir Sementsov-Ogievskiy
2019-10-03 17:15 ` [PATCH 5/6] block/block-copy: add memory limit Vladimir Sementsov-Ogievskiy
2019-10-07 15:27 ` Max Reitz
2019-10-07 17:10 ` Vladimir Sementsov-Ogievskiy
2019-10-08 9:03 ` Max Reitz
2019-10-08 9:15 ` Vladimir Sementsov-Ogievskiy
2019-10-08 9:20 ` Vladimir Sementsov-Ogievskiy
2019-10-08 9:57 ` Max Reitz
2019-10-08 9:56 ` Max Reitz [this message]
2019-10-03 17:15 ` [PATCH 6/6] block/block-copy: increase buffered copy request Vladimir Sementsov-Ogievskiy
2019-10-07 15:47 ` Max Reitz
2019-10-07 15:48 ` Max Reitz
2019-10-07 16:22 ` Vladimir Sementsov-Ogievskiy
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=73390228-76f4-1bc2-3a6f-a99f1422a6d6@redhat.com \
--to=mreitz@redhat.com \
--cc=den@virtuozzo.com \
--cc=jsnow@redhat.com \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=vsementsov@virtuozzo.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).