qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small re


From: Peter Lieven
Subject: Re: [Qemu-devel] [PATCH] block/io: optimize bdrv_co_pwritev for small requests
Date: Tue, 24 May 2016 16:07:23 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2

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?

Thanks,
Peter





reply via email to

[Prev in Thread] Current Thread [Next in Thread]