Re: SLUB: Support for statistics to help analyze allocator behavior

From: Christoph Lameter
Date: Wed Feb 06 2008 - 14:01:36 EST


On Wed, 6 Feb 2008, Andrew Morton wrote:

> > @@ -1357,17 +1366,22 @@ static struct page *get_partial(struct k
> > static void unfreeze_slab(struct kmem_cache *s, struct page *page, int tail)
> > {
> > struct kmem_cache_node *n = get_node(s, page_to_nid(page));
> > + struct kmem_cache_cpu *c = get_cpu_slab(s, smp_processor_id());
>
> So we're never running preemptibly here.

Correct.

> > + if (SlabDebug(page) && (s->flags & SLAB_STORE_USER))
> > add_full(n, page);
>
> missing a tab

Ack.

>
> > +#ifdef CONFIG_SLUB_STATS
> > +
> > +#define STAT_ATTR(si, text) \
> > +static ssize_t text##_show(struct kmem_cache *s, char *buf) \
> > +{ \
> > + unsigned long sum = 0; \
> > + int cpu; \
> > + \
> > + for_each_online_cpu(cpu) \
> > + sum += get_cpu_slab(s, cpu)->stat[si]; \
>
> maybe cache the get_cpu_slab() result in a local?

Every iteration must perform a different lookup. The cpu variable is
passed to get_cpu_slab().

>
> > + return sprintf(buf, "%lu\n", sum); \
> > +} \
> > +SLAB_ATTR_RO(text); \
>
> this is pretty broken after cpu hot-unplug, isn't it?

No it still gives all the events on the processors that are up which is
consistent in some way (and its only stats). There is really no clean
solution. Same situation as with the event counters in the VM. We could
fold them into some other processor when it goes down. Yuck.

--
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/