Re: [PATCH] kernel: use kcalloc instead kmalloc/memset

From: Takashi Iwai
Date: Tue Aug 09 2005 - 05:09:52 EST


At Mon, 8 Aug 2005 23:05:24 +0200,
Adrian Bunk wrote:
>
> On Mon, Aug 08, 2005 at 12:11:21PM +0200, Takashi Iwai wrote:
> > At Sat, 6 Aug 2005 17:09:40 +0200,
> > Adrian Bunk wrote:
> > >
> > >
> > > Looking at how few is left from kcalloc, can't we make it a
> > > "static inline" function in slab.h?
> > >
> > > This would optimize nicely for all of the users where the first or even
> > > the first two parameters are constant at compile-time and shouldn't do
> > > much harm for the other users.
> > >
> > > As a side effect, the difference between kcalloc(1, ...) and kzalloc()
> > > would become a coding style question without any effect on the generated
> > > code.
> >
> > How about to use __builtin_constant_p() like kmalloc?
> > The code readability would be worsen, though...
>
> Where should this make any difference?
>
> If the function is "static inline", gcc can e.g. always determine at
> compile-time that 1 >= 0 can never be false and therefore optimize it
> away.

Argh, forget my post. It was just lack of caffeine :)


Takashi
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/