[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero c
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero content in a buffer |
Date: |
Fri, 22 Mar 2013 13:37:54 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130311 Thunderbird/17.0.4 |
On 03/22/2013 06:46 AM, Peter Lieven wrote:
> this adds buffer_find_nonzero_offset() which is a SSE2/Altivec
> optimized function that searches for non-zero content in a
> buffer.
>
> due to the optimizations used in the function there are restrictions
> on buffer address and search length. the function
> can_use_buffer_find_nonzero_content() can be used to check if
> the function can be used safely.
>
> Signed-off-by: Peter Lieven <address@hidden>
> ---
> include/qemu-common.h | 13 +++++++++++++
> util/cutils.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 58 insertions(+)
> +#define BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR 8
> +static inline bool
> +can_use_buffer_find_nonzero_offset(const void *buf, size_t len)
> +{
> + if (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
> + * sizeof(VECTYPE)) == 0
> + && ((uintptr_t) buf) % sizeof(VECTYPE) == 0) {
I know that emacs tends to indent the second line to the column after
the ( that it is associated with, as in:
+ if (len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
+ * sizeof(VECTYPE)) == 0
+ && ((uintptr_t) buf) % sizeof(VECTYPE) == 0) {
But since checkpatch.pl didn't complain, and since I'm not sure if there
is a codified qemu indentation style, and since I _am_ sure that not
everyone uses emacs [hi, vi guys], it's not worth respinning. A
maintainer can touch it up if desired.
> +
> +size_t buffer_find_nonzero_offset(const void *buf, size_t len)
> +{
> + VECTYPE *p = (VECTYPE *)buf;
> + VECTYPE zero = ZERO_SPLAT;
> + size_t i;
> +
> + assert(len % (BUFFER_FIND_NONZERO_OFFSET_UNROLL_FACTOR
> + * sizeof(VECTYPE)) == 0);
> + assert(((uintptr_t) buf) % sizeof(VECTYPE) == 0);
I would have written this:
assert(can_use_buffer_find_nonzero_offset(buf, len));
But that's cosmetic, and compiles to the same code, so it's not worth a
respin.
You've addressed my concerns on v3.
Reviewed-by: Eric Blake <address@hidden>
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] [PATCHv4 3/9] buffer_is_zero: use vector optimizations if possible, (continued)
- [Qemu-devel] [PATCHv4 8/9] migration: do not search dirty pages in bulk stage, Peter Lieven, 2013/03/22
- [Qemu-devel] [PATCHv4 1/9] move vector definitions to qemu-common.h, Peter Lieven, 2013/03/22
- [Qemu-devel] [PATCHv4 9/9] migration: use XBZRLE only after bulk stage, Peter Lieven, 2013/03/22
- [Qemu-devel] [PATCHv4 4/9] bitops: use vector algorithm to optimize find_next_bit(), Peter Lieven, 2013/03/22
- [Qemu-devel] [PATCHv4 6/9] migration: add an indicator for bulk state of ram migration, Peter Lieven, 2013/03/22
- [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero content in a buffer, Peter Lieven, 2013/03/22
- Re: [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero content in a buffer,
Eric Blake <=
- Re: [Qemu-devel] [PATCHv4 2/9] cutils: add a function to find non-zero content in a buffer, Orit Wasserman, 2013/03/25
[Qemu-devel] [PATCHv4 7/9] migration: do not sent zero pages in bulk stage, Peter Lieven, 2013/03/22