From patchwork Fri Oct 7 16:17:34 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Bodireddy, Bhanuprakash" X-Patchwork-Id: 679466 X-Patchwork-Delegate: diproiettod@vmware.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3srFC563Zqz9sCZ for ; Sat, 8 Oct 2016 03:21:37 +1100 (AEDT) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7683C109DB; Fri, 7 Oct 2016 09:21:10 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx1e3.cudamail.com (mx1.cudamail.com [69.90.118.67]) by archives.nicira.com (Postfix) with ESMTPS id CAFC7109B7 for ; Fri, 7 Oct 2016 09:21:07 -0700 (PDT) Received: from bar5.cudamail.com (localhost [127.0.0.1]) by mx1e3.cudamail.com (Postfix) with ESMTPS id 60C01420792 for ; Fri, 7 Oct 2016 10:21:07 -0600 (MDT) X-ASG-Debug-ID: 1475857266-09eadd489f0e6e0001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar5.cudamail.com with ESMTP id IIpc3EziD67ejvLE (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Fri, 07 Oct 2016 10:21:06 -0600 (MDT) X-Barracuda-Envelope-From: bhanuprakash.bodireddy@intel.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mga05.intel.com) (192.55.52.43) by mx3-pf1.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 7 Oct 2016 16:21:06 -0000 Received-SPF: pass (mx3-pf1.cudamail.com: SPF record at intel.com designates 192.55.52.43 as permitted sender) X-Barracuda-Apparent-Source-IP: 192.55.52.43 X-Barracuda-RBL-IP: 192.55.52.43 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga105.fm.intel.com with ESMTP; 07 Oct 2016 09:21:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,456,1473145200"; d="scan'208";a="177488324" Received: from silpixa00393942.ir.intel.com ([10.237.223.42]) by fmsmga004.fm.intel.com with ESMTP; 07 Oct 2016 09:21:05 -0700 X-CudaMail-Envelope-Sender: bhanuprakash.bodireddy@intel.com From: Bhanuprakash Bodireddy To: dev@openvswitch.org X-CudaMail-MID: CM-V1-1006023418 X-CudaMail-DTE: 100716 X-CudaMail-Originating-IP: 192.55.52.43 Date: Fri, 7 Oct 2016 17:17:34 +0100 X-ASG-Orig-Subj: [##CM-V1-1006023418##][PATCH 04/12] hash: Skip invoking mhash_add__() with zero input. Message-Id: <1475857062-55311-5-git-send-email-bhanuprakash.bodireddy@intel.com> X-Mailer: git-send-email 2.4.11 In-Reply-To: <1475857062-55311-1-git-send-email-bhanuprakash.bodireddy@intel.com> References: <1475857062-55311-1-git-send-email-bhanuprakash.bodireddy@intel.com> X-GBUdb-Analysis: 0, 192.55.52.43, Ugly c=0 p=0 Source New X-MessageSniffer-Rules: 0-0-0-2946-c X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1475857266 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.60 X-Barracuda-Spam-Status: No, SCORE=0.60 using global scores of TAG_LEVEL=3.5 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=4.0 tests=BSF_SC5_MJ1963, RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.33545 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS 0.50 BSF_SC5_MJ1963 Custom Rule MJ1963 Subject: [ovs-dev] [PATCH 04/12] hash: Skip invoking mhash_add__() with zero input. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" mhash_add__() is expensive and should be only called with valid input. This patch will validate the input before invoking the mhash_add__ and there by saving some cpu cycles. Signed-off-by: Bhanuprakash Bodireddy Signed-off-by: Antonio Fischetti --- lib/hash.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/hash.h b/lib/hash.h index 114a419..9bfebdb 100644 --- a/lib/hash.h +++ b/lib/hash.h @@ -70,7 +70,7 @@ static inline uint32_t mhash_add__(uint32_t hash, uint32_t data) static inline uint32_t mhash_add(uint32_t hash, uint32_t data) { - hash = mhash_add__(hash, data); + hash = data ? mhash_add__(hash, data): hash; hash = hash_rot(hash, 13); return hash * 5 + 0xe6546b64; }