From: Hanna Czenczek <hreitz@redhat.com>
To: Stefan Hajnoczi <stefanha@redhat.com>, qemu-devel@nongnu.org
Cc: Kevin Wolf <kwolf@redhat.com>, Fiona Ebner <f.ebner@proxmox.com>,
qemu-block@nongnu.org, Fam Zheng <fam@euphon.net>,
Eric Blake <eblake@redhat.com>
Subject: Re: [PATCH v4 3/4] qemu-io: add -r option to register I/O buffer
Date: Wed, 8 Feb 2023 10:08:27 +0100 [thread overview]
Message-ID: <648e9201-eb76-61bd-d127-11c8605c9531@redhat.com> (raw)
In-Reply-To: <20230207203719.242926-4-stefanha@redhat.com>
On 07.02.23 21:37, Stefan Hajnoczi wrote:
> The blk_register_buf() API is an optimization hint that allows some
> block drivers to avoid I/O buffer housekeeping or bounce buffers.
>
> Add an -r option to register the I/O buffer so that qemu-io can be used
> to test the blk_register_buf() API. The next commit will add a test that
> uses the new option.
>
> Reviewed-by: Eric Blake <eblake@redhat.com>
> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> ---
> qemu-io-cmds.c | 204 +++++++++++++++++++++++++++++++------------------
> 1 file changed, 129 insertions(+), 75 deletions(-)
Reviewed-by: Hanna Czenczek <hreitz@redhat.com>
> diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c
> index 1f60c23ba4..e7a02f5b99 100644
> --- a/qemu-io-cmds.c
> +++ b/qemu-io-cmds.c
> @@ -414,24 +419,23 @@ static void *qemu_io_alloc_from_file(BlockBackend *blk, size_t len,
> fclose(f);
> f = NULL;
>
> - if (len > pattern_len) {
> - len -= pattern_len;
> - buf += pattern_len;
> -
> - while (len > 0) {
> - size_t len_to_copy = MIN(pattern_len, len);
> -
> - memcpy(buf, buf_origin, len_to_copy);
> + if (register_buf) {
> + blk_register_buf(blk, alloc_buf, alloc_len, &error_abort);
> + }
>
> - len -= len_to_copy;
> - buf += len_to_copy;
> - }
> + end = buf + len;
> + for (char *p = buf + pattern_len; p < end; p += pattern_len) {
> + memcpy(p, buf, MIN(pattern_len, end - p));
> }
Cool rewrite of this loop!
next prev parent reply other threads:[~2023-02-08 9:09 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-07 20:37 [PATCH v4 0/4] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF Stefan Hajnoczi
2023-02-07 20:37 ` [PATCH v4 1/4] " Stefan Hajnoczi
2023-02-07 20:37 ` [PATCH v4 2/4] qemu-io: use BdrvRequestFlags instead of int Stefan Hajnoczi
2023-02-07 20:37 ` [PATCH v4 3/4] qemu-io: add -r option to register I/O buffer Stefan Hajnoczi
2023-02-08 9:08 ` Hanna Czenczek [this message]
2023-02-07 20:37 ` [PATCH v4 4/4] iotests/detect-zeroes-registered-buf: add new test Stefan Hajnoczi
2023-02-09 15:24 ` [PATCH v4 0/4] block: fix detect-zeroes= with BDRV_REQ_REGISTERED_BUF Stefan Hajnoczi
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=648e9201-eb76-61bd-d127-11c8605c9531@redhat.com \
--to=hreitz@redhat.com \
--cc=eblake@redhat.com \
--cc=f.ebner@proxmox.com \
--cc=fam@euphon.net \
--cc=kwolf@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).