[Devel] [PATCH RHEL9 COMMIT] fuse: better check_zero

Konstantin Khorenko khorenko at virtuozzo.com
Wed Nov 1 22:44:32 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-284.25.1.vz9.30.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-284.25.1.vz9.30.8
------>
commit 4147b9a7f83862da25308c6e65c584b0952a5f8a
Author: Alexey Kuznetsov <kuznet at virtuozzo.com>
Date:   Fri Oct 6 18:42:49 2023 +0800

    fuse: better check_zero
    
    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?
    
    https://pmc.acronis.work/browse/VSTOR-54040
    
    Signed-off-by: Alexey Kuznetsov <kuznet at acronis.com>
    
    Feature: vStorage
---
 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 a76f28e2ae85..fc6a35fb17eb 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;


More information about the Devel mailing list