Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Adrian Bunk
On Mon, Aug 15, 2005 at 04:06:22PM +0300, Pekka J Enberg wrote: > On Mon, 2005-08-15 at 15:17 +0300, Denis Vlasenko wrote: > > > Seems like that optimization is not helping. > > > Do you have better example? > > On Mon, 15 Aug 2005, Arjan van de Ven wrote: > > you need gcc 4.1 (eg CVS) for the val

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Alan Cox
On Llu, 2005-08-15 at 16:06 +0300, Pekka J Enberg wrote: > and I saw small reduction in kernel text with kcalloc() inlined. If GCC > is, in fact, spreading the extra operations everywhere, shouldn't kernel > text be bigger? Only if the cost of the function call in lines of code is higher than t

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Pekka J Enberg
On Mon, 2005-08-15 at 15:17 +0300, Denis Vlasenko wrote: > > Seems like that optimization is not helping. > > Do you have better example? On Mon, 15 Aug 2005, Arjan van de Ven wrote: > you need gcc 4.1 (eg CVS) for the value range propagation stuff. For Denis' example, it does not seem to help. I

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Arjan van de Ven
On Mon, 2005-08-15 at 15:17 +0300, Denis Vlasenko wrote: > Seems like that optimization is not helping. > Do you have better example? you need gcc 4.1 (eg CVS) for the value range propagation stuff. - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a messa

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Denis Vlasenko
On Monday 15 August 2005 12:41, Arjan van de Ven wrote: > On Mon, 2005-08-15 at 12:33 +0300, Denis Vlasenko wrote: > > > gcc can optimize that away with non-const n?! I don't think so. > > due to the wonders of "value range propagation" it actually can, if the > check is done sufficiently before.

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Arjan van de Ven
On Mon, 2005-08-15 at 12:33 +0300, Denis Vlasenko wrote: > gcc can optimize that away with non-const n?! I don't think so. due to the wonders of "value range propagation" it actually can, if the check is done sufficiently before... gcc keeps track of the range a variable can have at each point,

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Denis Vlasenko
> > static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast > > flags) > > { > > if (__builtin_constant_p(n)) { > > if (n != 0 && size > INT_MAX / n) > > return NULL; > > return kzalloc(n * size, flags); > > } > > return kcal

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Pekka J Enberg
On Mon, 15 Aug 2005, Denis Vlasenko wrote: > Sure, I don't want to disable the check. I want that check to be > in _non-inlined function_. > > static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast > flags) > { > if (__builtin_constant_p(n)) { > if (n != 0 &&

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Denis Vlasenko
On Monday 15 August 2005 11:14, Arjan van de Ven wrote: > On Mon, 2005-08-15 at 11:06 +0300, Denis Vlasenko wrote: > > > > +static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast > > > flags) > > > +{ > > > + if (n != 0 && size > INT_MAX / n) > > > + return NULL; > > > +

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Arjan van de Ven
On Mon, 2005-08-15 at 11:06 +0300, Denis Vlasenko wrote: > > +static inline void *kcalloc(size_t n, size_t size, unsigned int __nocast > > flags) > > +{ > > + if (n != 0 && size > INT_MAX / n) > > + return NULL; > > + return kzalloc(n * size, flags); > > +} > Can you conditionalize

Re: [-mm patch] make kcalloc() a static inline

2005-08-15 Thread Denis Vlasenko
On Tuesday 09 August 2005 01:38, Adrian Bunk wrote: > kcalloc() doesn't do much more than calling kzalloc(), and gcc has > better optimizing opportunities when it's inlined. > > The result of this patch with a fulll kernel compile (roughly equivalent > to "make allyesconfig") shows a minimal siz

[-mm patch] make kcalloc() a static inline

2005-08-08 Thread Adrian Bunk
kcalloc() doesn't do much more than calling kzalloc(), and gcc has better optimizing opportunities when it's inlined. The result of this patch with a fulll kernel compile (roughly equivalent to "make allyesconfig") shows a minimal size improvement: text data bss dec