From afee2380c105c37e440aaa9ec588cd27189bc18e Mon Sep 17 00:00:00 2001 From: Mr NeilBrown Date: Tue, 21 Jul 2020 11:09:37 +1000 Subject: [PATCH] LU-12275 sec: use memchr_inv() to check if page is zero. 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 Change-Id: I0a5c3d30d5db43a3f5ebb270ea66b9db2b200a9a Reviewed-on: https://review.whamcloud.com/39459 Tested-by: Maloo Tested-by: jenkins Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Sebastien Buisson --- lustre/osc/osc_request.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index e190f74..bef2b26 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -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 */ -- 1.8.3.1