qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Peter Lieven <pl@kamp.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	qemu-block@nongnu.org, famz@redhat.com, qemu-devel@nongnu.org,
	mreitz@redhat.com, stefanha@redhat.com
Subject: Re: [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests
Date: Tue, 24 May 2016 16:22:22 +0200	[thread overview]
Message-ID: <20160524142222.GG7091@noname.redhat.com> (raw)
In-Reply-To: <5744601B.9040905@kamp.de>

Am 2.05.2016 um 16:07 hat Peter Lieven geschrieben:
> Am 24.05.2016 um 15:59 schrieb Paolo Bonzini:
> >
> >On 24/05/2016 15:39, Peter Lieven wrote:
> >>          bytes += offset & (align - 1);
> >>          offset = offset & ~(align - 1);
> >Because the low bits have been masked away from offset and added to bytes,
> >
> >>+
> >>+        /* if head and tail fall into the same alignment
> >>+         * we can omit the second read as it would read
> >>+         * the same block again */
> >>+        if ((offset + bytes) & (align - 1) &&
> >... the first part is just "bytes & (align - 1)"...
> >
> >>+            offset / align == (offset + bytes) / align) {
> >... and the second part is just "bytes < align" (you can distribute
> >division over addition because offset / align has no reminder, and
> >simplify to "0 == bytes / align").
> >
> >Putting it together, it becomes "bytes > 0 && bytes < align", or even
> >"bytes < align".
> 
> Oh, thanks, and the if block also too complicated. If I am right it should
> collapse to:
> 
>         if (bytes < align) {
>             qemu_iovec_add(&local_qiov, head_buf + bytes,
>                            align - bytes);
>             bytes = align;
>         }
> 
> Right?

Looks good to me.

Another mostly unrelated thing I just noticed while looking at this
code: Should we assert(is_power_of_2(align)) somewhere?

Kevin

      parent reply	other threads:[~2016-05-24 14:22 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-24 13:39 [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests Peter Lieven
2016-05-24 13:59 ` Paolo Bonzini
2016-05-24 14:07   ` Peter Lieven
2016-05-24 14:20     ` Paolo Bonzini
2016-05-24 14:22     ` Kevin Wolf [this message]

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=20160524142222.GG7091@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=famz@redhat.com \
    --cc=mreitz@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=pl@kamp.de \
    --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).