From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753041AbbDAHx0 (ORCPT ); Wed, 1 Apr 2015 03:53:26 -0400 Received: from bombadil.infradead.org ([198.137.202.9]:38583 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752340AbbDAHxZ (ORCPT ); Wed, 1 Apr 2015 03:53:25 -0400 Date: Wed, 1 Apr 2015 09:53:25 +0200 From: Peter Zijlstra To: Waiman Long 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 Message-ID: <20150401075325.GV27490@worktop.programming.kicks-ass.net> References: <1427822889-8783-1-git-send-email-Waiman.Long@hp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1427822889-8783-1-git-send-email-Waiman.Long@hp.com> User-Agent: Mutt/1.5.22.1 (2013-10-16) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + 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.