Re: [PATCH 4/4] kstat: modify kstat_irqs_legacy to be variable sized

Ingo Molnar
2009-01-11T12:18:10Z

* Yinghai Lu <yinghai@kernel.org> wrote:

> On Sat, Jan 10, 2009 at 2:38 PM, Mike Travis <travis@sgi.com> wrote:
> > Impact: reduce memory usage.
> >
> > Allocate kstat_irqs_legacy based on nr_cpu_ids to deal with this
> > memory usage bump when NR_CPUS bumped from 128 to 4096:
> >
> > 8192 +253952 262144 +3100% kstat_irqs_legacy(.bss)
> >
> > This is only when CONFIG_SPARSE_IRQS=y.
> >
> > Signed-off-by: Mike Travis <travis@sgi.com>
> > ---
> > kernel/irq/handle.c | 9 ++++++---
> > 1 file changed, 6 insertions(+), 3 deletions(-)
> >
> > --- linux-2.6-for-ingo.orig/kernel/irq/handle.c
> > +++ linux-2.6-for-ingo/kernel/irq/handle.c
> > @@ -124,8 +124,7 @@ static struct irq_desc irq_desc_legacy[N
> > }
> > };
> >
> > -/* FIXME: use bootmem alloc ...*/
> > -static unsigned int kstat_irqs_legacy[NR_IRQS_LEGACY][NR_CPUS];
> > +static unsigned int *kstat_irqs_legacy;
> >
> > int __init early_irq_init(void)
> > {
> > @@ -146,9 +145,13 @@ int __init early_irq_init(void)
> > /* allocate irq_desc_ptrs array based on nr_irqs */
> > irq_desc_ptrs = alloc_bootmem(nr_irqs * sizeof(void *));
> >
> > + /* allocate based on nr_cpu_ids */
> > + kstat_irqs_legacy = alloc_bootmem(NR_IRQS_LEGACY * nr_cpu_ids *
> > + sizeof(int));
> > +
> > for (i = 0; i < legacy_count; i++) {
> > desc[i].irq = i;
> > - desc[i].kstat_irqs = kstat_irqs_legacy[i];
> > + desc[i].kstat_irqs = kstat_irqs_legacy + i * NR_IRQS_LEGACY;
>
> here should be
>
> + desc[i].kstat_irqs = kstat_irqs_legacy + i * nr_cpu_ids;

indeed - i fixed this in tip/cpus4096.

Ingo