From patchwork Tue Oct 6 00:05:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Simmons X-Patchwork-Id: 11817897 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 22F811580 for ; Tue, 6 Oct 2020 00:06:54 +0000 (UTC) Received: from pdx1-mailman02.dreamhost.com (pdx1-mailman02.dreamhost.com [64.90.62.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EF4AB20760 for ; Tue, 6 Oct 2020 00:06:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EF4AB20760 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lustre-devel-bounces@lists.lustre.org Received: from pdx1-mailman02.dreamhost.com (localhost [IPv6:::1]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id 4A1CC2F59E3; Mon, 5 Oct 2020 17:06:44 -0700 (PDT) X-Original-To: lustre-devel@lists.lustre.org Delivered-To: lustre-devel-lustre.org@pdx1-mailman02.dreamhost.com Received: from smtp4.ccs.ornl.gov (smtp4.ccs.ornl.gov [160.91.203.40]) by pdx1-mailman02.dreamhost.com (Postfix) with ESMTP id BB05721F99B for ; Mon, 5 Oct 2020 17:06:30 -0700 (PDT) Received: from star.ccs.ornl.gov (star.ccs.ornl.gov [160.91.202.134]) by smtp4.ccs.ornl.gov (Postfix) with ESMTP id 18B4110087D4; Mon, 5 Oct 2020 20:06:25 -0400 (EDT) Received: by star.ccs.ornl.gov (Postfix, from userid 2004) id 173542F0E2; Mon, 5 Oct 2020 20:06:25 -0400 (EDT) From: James Simmons To: Andreas Dilger , Oleg Drokin , NeilBrown Date: Mon, 5 Oct 2020 20:05:52 -0400 Message-Id: <1601942781-24950-14-git-send-email-jsimmons@infradead.org> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1601942781-24950-1-git-send-email-jsimmons@infradead.org> References: <1601942781-24950-1-git-send-email-jsimmons@infradead.org> Subject: [lustre-devel] [PATCH 13/42] lustre: ptlrpc: prefer crc32_le() over CryptoAPI X-BeenThere: lustre-devel@lists.lustre.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "For discussing Lustre software development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lustre Development List MIME-Version: 1.0 Errors-To: lustre-devel-bounces@lists.lustre.org Sender: "lustre-devel" From: Andreas Dilger Prefer to call the crc32_le() library function directly if available, instead of cfs_crypto_hash(CFS_HASH_ALG_CRC32). It is about 10x faster for the 156-byte struct ptlrpc_body being checked in this function. A test of small buffers in that compares the two implementations, run on a 2.9GHz Core i7-7820 shows the difference is significant here: buffer size 156 bytes 1536 bytes 4096 bytes 1 MiB -----------+------------+------------+-----------+----------- cfs_crypto | 182 MiB/s | 1794 MiB/s | 4163 MB/s | 9631 MiB/s crc32_le | 1947 MiB/s | 1871 MiB/s | 1867 MB/s | 1823 MiB/s This corresponds to 10x faster or 1/10 as many cycles for ptlrpc_body. The CryptoAPI speed crosses over around 1536 bytes, which is still 10x larger than the ptlrpc_body size, so it is unlikely to be faster here. WC-bug-id: https://jira.whamcloud.com/browse/LU-13127 Lustre-commit: 1dda0ef6a70b2 ("LU-13127 ptlrpc: prefer crc32_le() over CryptoAPI") Signed-off-by: Andreas Dilger Reviewed-on: https://review.whamcloud.com/39614 Reviewed-by: Sebastien Buisson Reviewed-by: Alexey Lyashkov Reviewed-by: Oleg Drokin Signed-off-by: James Simmons --- fs/lustre/ptlrpc/pack_generic.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/fs/lustre/ptlrpc/pack_generic.c b/fs/lustre/ptlrpc/pack_generic.c index cbb65ce..fbed952 100644 --- a/fs/lustre/ptlrpc/pack_generic.c +++ b/fs/lustre/ptlrpc/pack_generic.c @@ -41,9 +41,7 @@ #define DEBUG_SUBSYSTEM S_RPC -#ifndef CONFIG_CRYPTO_CRC32 #include -#endif #include @@ -1240,15 +1238,16 @@ u32 lustre_msg_calc_cksum(struct lustre_msg *msg, u32 buf) struct ptlrpc_body *pb = lustre_msg_buf_v2(msg, buf, 0); u32 len = lustre_msg_buflen(msg, buf); u32 crc; -#ifdef CONFIG_CRYPTO_CRC32 + +#if IS_ENABLED(CONFIG_CRC32) + /* about 10x faster than crypto_hash for small buffers */ + crc = crc32_le(~(__u32)0, (unsigned char *)pb, len); +#elif IS_ENABLED(CONFIG_CRYPTO_CRC32) unsigned int hsize = 4; cfs_crypto_hash_digest(CFS_HASH_ALG_CRC32, (unsigned char *)pb, - lustre_msg_buflen(msg, - MSG_PTLRPC_BODY_OFF), - NULL, 0, (unsigned char *)&crc, &hsize); -#else - crc = crc32_le(~(__u32)0, (unsigned char *)pb, len); + len, NULL, 0, (unsigned char *)&crc, + &hsize); #endif return crc; }