Subject: Re: [PATCH] powerpc: Dynamically allocate pacas

From: Michael Ellerman <[email-masked]>
Date: Thu, 28 Jan 2010 09:47:25 +1100

On Wed, 2010-01-27 at 17:29 +1030, Michael Neuling wrote:
> > On 64-bit kernels we currently have a 512 byte struct paca_struct for
> > each cpu (usually just called "the paca"). Currently they are statically
> > allocated, which means a kernel built for a large number of cpus will
> > waste a lot of space if it's booted on a machine with few cpus.
> > 
> > We can avoid that by only allocating the number of pacas we need at
> > boot. However this is complicated by the fact that we need to access
> > the paca before we know how many cpus there are in the system.
> > 
> > The solution is to dynamically allocate enough space for NR_CPUS pacas,
> > but then later in boot when we know how many cpus we have, we free any
> > unused pacas.
> > 
> > Lightly booted on Legacy iSeries & pSeries LPAR.
> > 
> > Signed-off-by: Michael Ellerman <[email-masked]>
> 
> <snip>
> 
> > --- a/arch/powerpc/kernel/setup-common.c
> > +++ b/arch/powerpc/kernel/setup-common.c
> > @@ -493,6 +493,8 @@ void __init smp_setup_cpu_maps(void)
> >  	 * here will have to be reworked
> >  	 */
> >  	cpu_init_thread_core_maps(nthreads);
> > +
> > +	free_unused_pacas();
> 
> This is still barfing for me on 32bit.

Darn, what config? I built at least one :)

> Putting an #include <asm/paca.h> at the top of setup-common.c fixes it.

Gah, I saw it was coming via somewhere else but decided not to add it,
wrong decision :)

cheers