From mboxrd@z Thu Jan 1 00:00:00 1970 From: Vincent Bernat Subject: Re: [PATCH net-next v1] ipvs: fix multiplicative hashing in sh/dh/lblc/lblcr algorithms Date: Sun, 01 Apr 2018 12:16:10 +0200 Message-ID: References: <20180331222838.32758-1-vincent@bernat.im> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Cc: Wensong Zhang , Simon Horman , "David S. Miller" , netdev@vger.kernel.org, lvs-devel@vger.kernel.org To: Julian Anastasov Return-path: Received: from bart.luffy.cx ([78.47.78.131]:42482 "EHLO bart.luffy.cx" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753336AbeDAKWJ (ORCPT ); Sun, 1 Apr 2018 06:22:09 -0400 In-Reply-To: (Julian Anastasov's message of "Sun, 1 Apr 2018 11:11:08 +0300 (EEST)") Sender: netdev-owner@vger.kernel.org List-ID: =E2=9D=A6 1 avril 2018 11:11 +0300, Julian Anastasov =C2=A0: >> - return (ntohl(addr_fold)*2654435761UL) & IP_VS_DH_TAB_MASK; >> + return ((ntohl(addr_fold)*2654435761U) >> >> + (32 - IP_VS_DH_TAB_BITS)) & >> + IP_VS_DH_TAB_MASK; > > Looks like the '& mask' part is not needed, still, > it does not generate extra code. I see that other code uses > hash_32(val, bits) from include/linux/hash.h but note that it > used different ratio before Linux 4.7, in case someone backports > this patch on old kernels. So, I don't have preference what should > be used, may be return hash_32(ntohl(addr_fold), IP_VS_DH_TAB_BITS) > is better. I didn't notice this macro. I think this is a better option. Let me amend the patch. --=20 Don't stop with your first draft. - The Elements of Programming Style (Kernighan & Plauger)