This version of check_zero is the same on non-zero areas, but ~2 times faster on zero areas. Though benchmark was done in userspace, memcmp may be different there
It is strange. Linux should provide a good function doing this. Did I miss it? Signed-off-by: Alexey Kuznetsov <kuz...@acronis.com> --- fs/fuse/kio/pcs/pcs_cs_accel.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/fuse/kio/pcs/pcs_cs_accel.c b/fs/fuse/kio/pcs/pcs_cs_accel.c index a76f28e..fc6a35f 100644 --- a/fs/fuse/kio/pcs/pcs_cs_accel.c +++ b/fs/fuse/kio/pcs/pcs_cs_accel.c @@ -278,13 +278,10 @@ static int verify_crc(struct pcs_int_request * ireq, u32 * crc) static int check_zero(struct page * page, unsigned int offset) { u64 * addr = kmap(page) + offset; - int i; - for (i = 0; i < 512/8; i++) { - if (likely(addr[i] != 0)) { - kunmap(page); - return 0; - } + if (likely(addr[0] || memcmp(addr, addr + 1, 512 - 8))) { + kunmap(page); + return 0; } kunmap(page); return 1; -- 1.8.3.1 _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel