From: Eric Blake <eblake@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: "Denis V. Lunev" <den@openvz.org>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
Max Reitz <mreitz@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [Qemu-devel] [PATCH v3 5/5] qcow2: Catch more unaligned write_zero into zero cluster
Date: Thu, 2 Jun 2016 06:33:48 -0600 [thread overview]
Message-ID: <575027AC.5070004@redhat.com> (raw)
In-Reply-To: <20160602101450.GA6867@noname.redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1689 bytes --]
On 06/02/2016 04:14 AM, Kevin Wolf wrote:
>> If you prefer, I could have written '-tail % s->cluster_sectors', but as
>> % on a negative signed integer gives different results than what you get
>> for an unsigned number, I felt that & was nicer than % for making it
>> more obvious that I'm grabbing particular bits.
>>
>> If you can think of any cleaner expression that represents the number of
>> sectors occurring after the tail until the next cluster boundary, I'm
>> game; the hardest part is that when tail is 0, we want the number passed
>> to is_zero_sectors() to also be 0, not s->cluster_sectors (so the naive
>> 's->cluster_sectors - tail' is wrong).
>
> The obvious one would be translating your English into C:
>
> tail ? s->cluster_sectors - tail : 0
Would gcc optimize this into a bit operation rather than a branch? If
not, that's a missed optimization bug that we should probably report
(that is, if gcc has enough information elsewhere that
s->cluster_sectors is a power of 2, since the bit operation optimization
depends on that fact).
>
> Another option which doesn't require an unsigned type would be
> (s->cluster_sectors - tail) % s->cluster_sectors.
That's the same thing as '-tail % s->cluster_sectors', since the
distributive rule applies to modulo arithmetic, and since 'a % a' is 0
for non-zero 'a'. So you can argue I was just saving typing :)
>
> I'm okay with merging the "more interesting" version, though I must
> admit that I had to read it twice.
That's certainly your call as maintainer :)
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-06-02 12:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 3:48 [Qemu-devel] [PATCH v3 0/5] qcow2_co_write_zeroes and related improvements Eric Blake
2016-05-26 3:48 ` [Qemu-devel] [PATCH v3 1/5] block: split write_zeroes always Eric Blake
2016-05-26 8:51 ` Fam Zheng
2016-05-26 3:48 ` [Qemu-devel] [PATCH v3 2/5] qcow2: simplify logic in qcow2_co_write_zeroes Eric Blake
2016-05-26 3:48 ` [Qemu-devel] [PATCH v3 3/5] qcow2: add tracepoints for qcow2_co_write_zeroes Eric Blake
2016-05-26 3:48 ` [Qemu-devel] [PATCH v3 4/5] qemu-iotests: Test one more spot for optimizing write_zeroes Eric Blake
2016-05-26 3:48 ` [Qemu-devel] [PATCH v3 5/5] qcow2: Catch more unaligned write_zero into zero cluster Eric Blake
2016-05-26 13:41 ` Denis V. Lunev
2016-05-26 14:35 ` Eric Blake
2016-06-02 10:14 ` Kevin Wolf
2016-06-02 12:33 ` Eric Blake [this message]
2016-05-26 14:56 ` Denis V. Lunev
2016-06-02 10:20 ` [Qemu-devel] [PATCH v3 0/5] qcow2_co_write_zeroes and related improvements Kevin Wolf
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=575027AC.5070004@redhat.com \
--to=eblake@redhat.com \
--cc=den@openvz.org \
--cc=kwolf@redhat.com \
--cc=mreitz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.