[Cbe-oss-dev] [PATCH 06/14] spufs: fix array size of channel index

Andrew Morton akpm at linux-foundation.org
Sat Jul 21 04:48:52 EST 2007


On Fri, 20 Jul 2007 15:21:17 +1000
Jeremy Kerr <jk at ozlabs.org> wrote:

> --- a/arch/powerpc/platforms/cell/spufs/switch.c
> +++ b/arch/powerpc/platforms/cell/spufs/switch.c
> @@ -616,7 +616,7 @@ static inline void save_ppuint_mb(struct spu_state *csa, struct spu *spu)
>  static inline void save_ch_part1(struct spu_state *csa, struct spu *spu)
>  {
>  	struct spu_priv2 __iomem *priv2 = spu->priv2;
> -	u64 idx, ch_indices[7] = { 0UL, 3UL, 4UL, 24UL, 25UL, 27UL };
> +	u64 idx, ch_indices[] = { 0UL, 3UL, 4UL, 24UL, 25UL, 27UL };

this definition of ch_indices[] will cause the compiler to create and
initialise a new copy of the array on the stack each time this function is
called.  It's better to do this at compile-time: make it `static const'. 
There are several instances of this in there.

Also, this function is far too large to inline.  Remove the `inline' and,
as it has a single callsite, the compiler will inline it anyway.  If later
you add a second callsite you don't _want_ this function inlined, and the
compiler will dtrt thing then too, (at least, it should).

`inline' is only ever needed on really super-small functions.



More information about the cbe-oss-dev mailing list