RE: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-17 Thread David Laight
From: Hannes Frederic Sowa > On Thu, Jan 16, 2014 at 10:37:37AM -0600, Christoph Lameter wrote: > > On Thu, 16 Jan 2014, Daniel Borkmann wrote: > > > > > - * or else the performance is slower than a normal divide. > > > - */ > > > -extern u32 reciprocal_value(u32 B); > > > +struct reciprocal_value

RE: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-17 Thread David Laight
From: Hannes Frederic Sowa On Thu, Jan 16, 2014 at 10:37:37AM -0600, Christoph Lameter wrote: On Thu, 16 Jan 2014, Daniel Borkmann wrote: - * or else the performance is slower than a normal divide. - */ -extern u32 reciprocal_value(u32 B); +struct reciprocal_value { + u32 m;

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Ben Hutchings
On Thu, 2014-01-16 at 10:37 -0600, Christoph Lameter wrote: > On Thu, 16 Jan 2014, Daniel Borkmann wrote: > > > - * or else the performance is slower than a normal divide. > > - */ > > -extern u32 reciprocal_value(u32 B); > > +struct reciprocal_value { > > + u32 m; > > + u8 sh1, sh2; > > +};

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Hannes Frederic Sowa
On Thu, Jan 16, 2014 at 10:37:37AM -0600, Christoph Lameter wrote: > On Thu, 16 Jan 2014, Daniel Borkmann wrote: > > > - * or else the performance is slower than a normal divide. > > - */ > > -extern u32 reciprocal_value(u32 B); > > +struct reciprocal_value { > > + u32 m; > > + u8 sh1, sh2; >

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Christoph Lameter
On Thu, 16 Jan 2014, Daniel Borkmann wrote: > - * or else the performance is slower than a normal divide. > - */ > -extern u32 reciprocal_value(u32 B); > +struct reciprocal_value { > + u32 m; > + u8 sh1, sh2; > +}; > > +#define RECIPROCAL_VALUE_RESULT_TO_ZERO ((struct

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Hannes Frederic Sowa
Hi Eric! On Wed, Jan 15, 2014 at 07:07:26PM -0800, Eric Dumazet wrote: > On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: > > > Also, reciprocal_value() and reciprocal_divide() always return 0 > > for divisions by 1. This is a bit worrisome as those functions > > also get used in

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Hannes Frederic Sowa
Hi Eric! On Wed, Jan 15, 2014 at 07:07:26PM -0800, Eric Dumazet wrote: On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: Also, reciprocal_value() and reciprocal_divide() always return 0 for divisions by 1. This is a bit worrisome as those functions also get used in mm/slab.c and

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Christoph Lameter
On Thu, 16 Jan 2014, Daniel Borkmann wrote: - * or else the performance is slower than a normal divide. - */ -extern u32 reciprocal_value(u32 B); +struct reciprocal_value { + u32 m; + u8 sh1, sh2; +}; +#define RECIPROCAL_VALUE_RESULT_TO_ZERO ((struct reciprocal_value){.sh1 =

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Hannes Frederic Sowa
On Thu, Jan 16, 2014 at 10:37:37AM -0600, Christoph Lameter wrote: On Thu, 16 Jan 2014, Daniel Borkmann wrote: - * or else the performance is slower than a normal divide. - */ -extern u32 reciprocal_value(u32 B); +struct reciprocal_value { + u32 m; + u8 sh1, sh2; +};

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-16 Thread Ben Hutchings
On Thu, 2014-01-16 at 10:37 -0600, Christoph Lameter wrote: On Thu, 16 Jan 2014, Daniel Borkmann wrote: - * or else the performance is slower than a normal divide. - */ -extern u32 reciprocal_value(u32 B); +struct reciprocal_value { + u32 m; + u8 sh1, sh2; +}; +#define

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Eric Dumazet
On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: > Also, reciprocal_value() and reciprocal_divide() always return 0 > for divisions by 1. This is a bit worrisome as those functions > also get used in mm/slab.c and lib/flex_array.c, apparently for > index calculation to access array

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Hannes Frederic Sowa
On Thu, Jan 16, 2014 at 12:17:50AM +, Ben Hutchings wrote: > On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: > [...] > > --- a/include/linux/reciprocal_div.h > > +++ b/include/linux/reciprocal_div.h > [...] > > + * RECIPROCAL_VALUE_TO_ZERO can be used to express an element, which > >

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Ben Hutchings
On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: [...] > --- a/include/linux/reciprocal_div.h > +++ b/include/linux/reciprocal_div.h [...] > + * RECIPROCAL_VALUE_TO_ZERO can be used to express an element, which > + * used as the argument to reciprocal_divide always yields zero. > */

[PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Daniel Borkmann
From: Hannes Frederic Sowa Jakub Zawadzki noticed that some divisions by reciprocal_divide() were not correct [1][2], which he could also show with BPF code after divisions are transformed into reciprocal_value() for runtime invariant which can be passed to reciprocal_divide() later on; reverse

[PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Daniel Borkmann
From: Hannes Frederic Sowa han...@stressinduktion.org Jakub Zawadzki noticed that some divisions by reciprocal_divide() were not correct [1][2], which he could also show with BPF code after divisions are transformed into reciprocal_value() for runtime invariant which can be passed to

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Ben Hutchings
On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: [...] --- a/include/linux/reciprocal_div.h +++ b/include/linux/reciprocal_div.h [...] + * RECIPROCAL_VALUE_TO_ZERO can be used to express an element, which + * used as the argument to reciprocal_divide always yields zero. */ [...]

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Hannes Frederic Sowa
On Thu, Jan 16, 2014 at 12:17:50AM +, Ben Hutchings wrote: On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: [...] --- a/include/linux/reciprocal_div.h +++ b/include/linux/reciprocal_div.h [...] + * RECIPROCAL_VALUE_TO_ZERO can be used to express an element, which + * used

Re: [PATCH net-next 2/2] reciprocal_divide: correction/update of the algorithm

2014-01-15 Thread Eric Dumazet
On Thu, 2014-01-16 at 00:23 +0100, Daniel Borkmann wrote: Also, reciprocal_value() and reciprocal_divide() always return 0 for divisions by 1. This is a bit worrisome as those functions also get used in mm/slab.c and lib/flex_array.c, apparently for index calculation to access array slots.