From: Orit Wasserman <owasserm@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: peter.maydell@linaro.org, aliguori@us.ibm.com,
quintela@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org,
mdroth@linux.vnet.ibm.com, blauwirbel@gmail.com,
Petter Svard <petters@cs.umu.se>,
Benoit Hudzia <benoit.hudzia@sap.com>,
avi@redhat.com, Aidan Shribman <aidan.shribman@sap.com>,
pbonzini@redhat.com, chegu_vinod@hp.com
Subject: Re: [Qemu-devel] [PATCH v15 6/9] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions
Date: Thu, 05 Jul 2012 21:01:11 +0300 [thread overview]
Message-ID: <4FF5D667.6070300@redhat.com> (raw)
In-Reply-To: <4FF59CD8.4080103@redhat.com>
On 07/05/2012 04:55 PM, Eric Blake wrote:
> On 07/05/2012 06:51 AM, Orit Wasserman wrote:
>
> This commit message is a bit sparse. I'd document at least the fact
> that our nzrun detection code in xbzrle_encode_buffer borrows
> long-word-at-a-time NUL-detection tricks from strcmp(), as it is not an
> intuitive trick known by all developers.
>
>> Signed-off-by: Benoit Hudzia <benoit.hudzia@sap.com>
>> Signed-off-by: Petter Svard <petters@cs.umu.se>
>> Signed-off-by: Aidan Shribman <aidan.shribman@sap.com>
>> Signed-off-by: Orit Wasserman <owasserm@redhat.com>
>
> I think I touched this one heavily enough that it warrants adding:
>
> Signed-off-by: Eric Blake <eblake@redhat.com>
>
Of course
Orit
> Other than the commit message, I'm happy with this patch contents now.
> Still some nits, though:
>
>> +
>> + /* not aligned to sizeof(long) */
>> + res = (slen - i) % sizeof(long);
>
> Comment indentation is off.
>
>> + while (res && old_buf[i] == new_buf[i]) {
>> + zrun_len++;
>> + i++;
>> + res--;
>> + }
>> +
>> + if (!res) {
>
> A comment here might help:
>
> /* word at a time for speed */
>
>> + while (i < slen &&
>> + (*(long *)(old_buf + i)) == (*(long *)(new_buf + i))) {
>
> On re-reading this, I'm worried whether it violates strict C99 aliasing
> rules; I'm hoping the compiler doesn't mis-optimize it based on a
> loophole of us using questionable semantics. In practice, I'm confident
> that we are only doing aligned reads (otherwise I wouldn't have
> suggested this line in the first place), which is why I'm personally
> okay with it even if it technically violates C99. However, I'm open to
> suggestions from anyone else on the list on how to better express the
> notion of intentionally accessing a long at a time from an aligned
> offset into a byte array, if that will help us avoid even theoretical
> problems.
This is a very interesting question ....
Orit
>
>> + nzrun_len++;
>> + res--;
>> + }
>> +
>> + if (!res) {
>> + /* truncation to 32-bit long okay */
>
> Again, a longer comment might help:
>
> /* word at a time for speed, use of 32-bit long okay */
>
>> + long mask = 0x0101010101010101ULL;
>> + while (i < slen) {
>> + xor = *(long *)(old_buf + i) ^ *(long *)(new_buf + i);
>
> Same potential strict aliasing problems as for zrun detection.
>
next prev parent reply other threads:[~2012-07-05 18:01 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-07-05 12:51 [Qemu-devel] [PATCH v15 0/9] XBZRLE delta for live migration of large memory app Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 1/9] Add migration capabilities Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 2/9] Add XBZRLE documentation Orit Wasserman
2012-07-05 13:24 ` Eric Blake
2012-07-05 17:22 ` Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 3/9] Add cache handling functions Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 4/9] Add uleb encoding/decoding functions Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 5/9] Change ram_save_block to return -1 if there are no more changes Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 6/9] Add xbzrle_encode_buffer and xbzrle_decode_buffer functions Orit Wasserman
2012-07-05 13:55 ` Eric Blake
2012-07-05 18:01 ` Orit Wasserman [this message]
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 7/9] Add XBZRLE to ram_save_block and ram_save_live Orit Wasserman
2012-07-05 14:04 ` Eric Blake
2012-07-06 5:23 ` Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 8/9] Add set_cachesize command Orit Wasserman
2012-07-05 14:14 ` Eric Blake
2012-07-06 5:24 ` Orit Wasserman
2012-07-05 12:51 ` [Qemu-devel] [PATCH v15 9/9] Add XBZRLE statistics Orit Wasserman
2012-07-05 14:20 ` Eric Blake
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=4FF5D667.6070300@redhat.com \
--to=owasserm@redhat.com \
--cc=aidan.shribman@sap.com \
--cc=aliguori@us.ibm.com \
--cc=avi@redhat.com \
--cc=benoit.hudzia@sap.com \
--cc=blauwirbel@gmail.com \
--cc=chegu_vinod@hp.com \
--cc=eblake@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=petters@cs.umu.se \
--cc=qemu-devel@nongnu.org \
--cc=quintela@redhat.com \
--cc=stefanha@gmail.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).