Whamcloud - gitweb
LU-12275 sec: use memchr_inv() to check if page is zero. 59/39459/3
authorMr NeilBrown <neilb@suse.de>
Tue, 21 Jul 2020 01:09:37 +0000 (11:09 +1000)
committerOleg Drokin <green@whamcloud.com>
Thu, 13 Aug 2020 05:58:43 +0000 (05:58 +0000)
memchr_inv() is the preferred way to check if a memory region is all
zeros.  It is likely fast that memcmp() is it doesn't need to read the
ZERO_PAGE into cache, or into the CPU.  It was introduced in Linux
3.2.

Test-Parameters: trivial
Signed-off-by: Mr NeilBrown <neilb@suse.de>
Change-Id: I0a5c3d30d5db43a3f5ebb270ea66b9db2b200a9a
Reviewed-on: https://review.whamcloud.com/39459
Tested-by: Maloo <maloo@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
lustre/osc/osc_request.c

index e190f74..bef2b26 100644 (file)
@@ -2058,9 +2058,8 @@ static int osc_brw_fini_request(struct ptlrpc_request *req, int rc)
                        struct brw_page *pg = aa->aa_ppga[idx];
 
                        /* do not decrypt if page is all 0s */
-                       if (memcmp(page_address(pg->pg),
-                                  page_address(ZERO_PAGE(0)),
-                                  PAGE_SIZE) == 0) {
+                       if (memchr_inv(page_address(pg->pg), 0,
+                                      PAGE_SIZE) == NULL) {
                                /* if page is empty forward info to upper layers
                                 * (ll_io_zero_page) by clearing PagePrivate2
                                 */