From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753517AbbDAOQH (ORCPT ); Wed, 1 Apr 2015 10:16:07 -0400 Received: from g2t1383g.austin.hp.com ([15.217.136.92]:43908 "EHLO g2t1383g.austin.hp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753240AbbDAOQE (ORCPT ); Wed, 1 Apr 2015 10:16:04 -0400 Message-ID: <551BFD9F.2030403@hp.com> Date: Wed, 01 Apr 2015 10:15:59 -0400 From: Waiman Long User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:10.0.12) Gecko/20130109 Thunderbird/10.0.12 MIME-Version: 1.0 To: Peter Zijlstra CC: Ingo Molnar , linux-kernel@vger.kernel.org, Shuah Khan , Scott J Norton , Douglas Hatch Subject: Re: [PATCH] lfsr: a simple binary Galois linear feedback shift register References: <1427822889-8783-1-git-send-email-Waiman.Long@hp.com> <20150401075325.GV27490@worktop.programming.kicks-ass.net> In-Reply-To: <20150401075325.GV27490@worktop.programming.kicks-ass.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 04/01/2015 03:53 AM, Peter Zijlstra wrote: > On Tue, Mar 31, 2015 at 01:28:09PM -0400, Waiman Long wrote: >> +static __always_inline u32 lfsr_taps(int bits) >> +static inline u32 lfsr(u32 val, int bits) >> +{ >> + u32 bit = val& 1; >> + >> + /* >> + * LFSR doesn't work with a start state of 0, so force it to a >> + * non-zero value (bits) as the next state. >> + */ >> + if (val == 0) >> + return bits; > Arguably this should be a debug/warn instead of a silent modification. Since it is used in conjunction with hashing, it is possible that hashing can produce a value of 0. Do we really want to have a warning for that? Alternatively, we can pass in some flag to decide if a warning should be issued. >> + val>>= 1; >> + if (bit) >> + val ^= lfsr_taps(bits); >> + return val; >> +} > I was also thinking that if we modify the hash to be dynamically signed > we cannot use the compile time tap selection and need to change the > interface slightly. So you mean having another argument for the caller to pass in the tap value instead of using the default. Right? -Longman