From: Kevin Wolf <kwolf@redhat.com>
To: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
Cc: Max Reitz <mreitz@redhat.com>,
"qemu-devel@nongnu.org" <qemu-devel@nongnu.org>,
"qemu-block@nongnu.org" <qemu-block@nongnu.org>,
Denis Lunev <den@virtuozzo.com>
Subject: Re: [Qemu-devel] [PATCH 3/7] qcow2: split out reading normal clusters from qcow2_co_preadv
Date: Thu, 8 Nov 2018 11:33:34 +0100 [thread overview]
Message-ID: <20181108103334.GB6006@linux.fritz.box> (raw)
In-Reply-To: <df8e5a97-c79c-c8c2-6dd4-7373239d6601@virtuozzo.com>
Am 08.11.2018 um 11:02 hat Vladimir Sementsov-Ogievskiy geschrieben:
> 07.11.2018 21:16, Kevin Wolf wrote:
> > (Broken quoting in text/plain again)
> >
> > Am 01.11.2018 um 13:17 hat Vladimir Sementsov-Ogievskiy geschrieben:
> >> 27.09.2018 20:35, Max Reitz wrote:
> >>
> >> On 07.08.18 19:43, Vladimir Sementsov-Ogievskiy wrote:
> >>
> >> Memory allocation may become less efficient for encrypted case. It's a
> >> payment for further asynchronous scheme.
> >>
> >> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
> >> ---
> >> block/qcow2.c | 114 ++++++++++++++++++++++++++++++++--------------------------
> >> 1 file changed, 64 insertions(+), 50 deletions(-)
> >>
> >> diff --git a/block/qcow2.c b/block/qcow2.c
> >> index 65e3ca00e2..5e7f2ee318 100644
> >> --- a/block/qcow2.c
> >> +++ b/block/qcow2.c
> >> @@ -1808,6 +1808,67 @@ out:
> >> return ret;
> >> }
> >>
> >> +static coroutine_fn int qcow2_co_preadv_normal(BlockDriverState *bs,
> >> + uint64_t file_cluster_offset,
> >> + uint64_t offset,
> >> + uint64_t bytes,
> >> + QEMUIOVector *qiov,
> >> + uint64_t qiov_offset)
> >> +{
> >> + int ret;
> >> + BDRVQcow2State *s = bs->opaque;
> >> + void *crypt_buf = NULL;
> >> + QEMUIOVector hd_qiov;
> >> + int offset_in_cluster = offset_into_cluster(s, offset);
> >> +
> >> + if ((file_cluster_offset & 511) != 0) {
> >> + return -EIO;
> >> + }
> >> +
> >> + qemu_iovec_init(&hd_qiov, qiov->niov);
> >>
> >> So you're not just re-allocating the bounce buffer for every single
> >> call, but also this I/O vector. Hm.
> > And this one is actually at least a little more serious, I think.
> >
> > Decryption and decompression (including copying between the original
> > qiov and the bounce buffer) are already very slow, so allocating a
> > bounce buffer or not shouldn't make any noticable difference.
> >
> > But I'd like to keep allocations out of the fast path as much as we can.
> >
> >> + if (bs->encrypted) {
> >> + assert(s->crypto);
> >> + assert(bytes <= QCOW_MAX_CRYPT_CLUSTERS * s->cluster_size);
> >> +
> >> + crypt_buf = qemu_try_blockalign(bs->file->bs, bytes);
> >>
> >> 1. Why did you remove the comment?
> >>
> >> 2. The check for whether crypt_buf was successfully allocated is missing.
> >>
> >> 3. Do you have any benchmarks for encrypted images? Having to allocate
> >> the bounce buffer for potentially every single cluster sounds rather bad
> >> to me.
> > Actually, benchmarks for normal, fully allocated images would be a
> > little more interesting. Though I'm not sure if qcow2 actually performs
> > well enough that we'll see any difference even there (when we measured
> > memory allocation overhead etc. for raw images in the context of
> > comparing coroutines to AIO callback styes, the difference was already
> > hard to see).
>
> Ok, I'll benchmark it and/or improve fast path (you mean code path,
> where we skip coroutines creation, to handle the whole request at once,
> yes?).
I had less the specific code path in mind, but the case of reading
unallocated clusters or reading/writing an already allocated area of
normal or zero clusters (no compression, no encrpytion, no other fancy
stuff). These are the cases that qcow2 images will hit the most in
practice.
> Hmm, all this staff with hd_qiov's in many places is due to we don't
> have qiov_offset parameter in .bdrv_co_preadv.. Is it a bad idea to
> add it?
I actually thought the same yesterday, though I'm not completely sure
yet about it. It makes the interfaces a bit uglier, but it could indeed
save us some work in the I/O path, so unless we find bigger reasons
against it, maybe we should do that.
> Anyway, I now think, it's better to start with decompress-threads
> series, as compress-threads are already merged, then bring encryption to
> threads too, and then return to these series. This way will remove some
> questions about allocation, and may be it would be simpler and more
> consistent to bring more things to coroutines, not only normal clusters.
Okay, we can do that.
Kevin
next prev parent reply other threads:[~2018-11-08 10:33 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-07 17:43 [Qemu-devel] [PATCH 0/7] qcow2: async handling of fragmented io Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 1/7] qcow2: move qemu_co_mutex_lock below decryption procedure Vladimir Sementsov-Ogievskiy
[not found] ` <8e1cc18c-307f-99b1-5892-713ebd17a15f@redhat.com>
[not found] ` <43277786-b6b9-e18c-b0ca-064ff7c9c0c9@redhat.com>
2018-10-01 15:56 ` Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 2/7] qcow2: bdrv_co_pwritev: move encryption code out of lock Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 3/7] qcow2: split out reading normal clusters from qcow2_co_preadv Vladimir Sementsov-Ogievskiy
[not found] ` <6e19aaeb-8acc-beb9-5ece-9ae6101637a9@redhat.com>
2018-10-01 15:14 ` Vladimir Sementsov-Ogievskiy
2018-10-01 15:39 ` Max Reitz
2018-10-01 16:00 ` Vladimir Sementsov-Ogievskiy
2018-11-01 12:17 ` Vladimir Sementsov-Ogievskiy
2018-11-07 13:51 ` Max Reitz
2018-11-07 18:16 ` Kevin Wolf
2018-11-08 10:02 ` Vladimir Sementsov-Ogievskiy
2018-11-08 10:33 ` Kevin Wolf [this message]
2018-11-08 12:36 ` Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 4/7] qcow2: async scheme for qcow2_co_preadv Vladimir Sementsov-Ogievskiy
[not found] ` <08a610aa-9c78-1c83-5e48-b93080aac87b@redhat.com>
2018-10-01 15:33 ` Vladimir Sementsov-Ogievskiy
2018-10-01 15:49 ` Max Reitz
2018-10-01 16:17 ` Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 5/7] qcow2: refactor qcow2_co_pwritev: split out qcow2_co_do_pwritev Vladimir Sementsov-Ogievskiy
[not found] ` <5c871ce7-2cab-f897-0b06-cbc05b9ffe97@redhat.com>
2018-10-01 15:43 ` Vladimir Sementsov-Ogievskiy
2018-10-01 15:50 ` Max Reitz
2018-08-07 17:43 ` [Qemu-devel] [PATCH 6/7] qcow2: refactor qcow2_co_pwritev locals scope Vladimir Sementsov-Ogievskiy
2018-08-07 17:43 ` [Qemu-devel] [PATCH 7/7] qcow2: async scheme for qcow2_co_pwritev Vladimir Sementsov-Ogievskiy
[not found] ` <1c8299bf-0b31-82a7-c7c4-5069581f2d94@redhat.com>
2018-10-01 15:46 ` Vladimir Sementsov-Ogievskiy
2018-08-16 0:51 ` [Qemu-devel] [PATCH 0/7] qcow2: async handling of fragmented io Max Reitz
2018-08-16 13:58 ` Vladimir Sementsov-Ogievskiy
2018-08-17 19:34 ` Max Reitz
2018-08-17 19:43 ` Denis V. Lunev
2018-08-20 16:33 ` Vladimir Sementsov-Ogievskiy
2018-08-20 16:39 ` Max Reitz
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=20181108103334.GB6006@linux.fritz.box \
--to=kwolf@redhat.com \
--cc=den@virtuozzo.com \
--cc=mreitz@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).