Re: [PATCH UPDATED] percpu: use dynamic percpu allocator as thedefault percpu allocator

From: Ingo Molnar
Date: Wed Apr 01 2009 - 22:13:06 EST



* Matthew Wilcox <matthew@xxxxxx> wrote:

> On Thu, Apr 02, 2009 at 12:32:41AM +0200, Ingo Molnar wrote:
> > And free_percpu(NULL) does this:
> >
> > void free_percpu(void *ptr)
> > {
> > void *addr = __pcpu_ptr_to_addr(ptr);
> > struct pcpu_chunk *chunk;
> > unsigned long flags;
> > int off;
> >
> > if (!ptr)
> > return;
>
> Why don't we rewrite this as:
>
> - void *addr = __pcpu_ptr_to_addr(ptr);
> + void *addr;
> ...
> if (!ptr)
> return;
> addr = __pcpu_ptr_to_addr(ptr);
>
> if kfree(NULL) is really that important, we should avoid doing this
> extra work, not just rely on the variable being cache-hot.

Yes, of course we can fix that, the NULL fastpath needs no access to
anything but the call parameter.

Note that my argument was different though: that assumptions about
variable correlation are very hard to track and validate, and that
IMHO we should be using __read_mostly generously (we know _that_
attribute with a rather high likelyhood), and we should group the
remaining variables together, starting at a cacheline aligned
address.

A sub-argument was that the boundary between global variables from
different .o files should perhaps not be 'merged' together (on SMP),
because the sharing effects are not maintainable: an example of
badness is the sb_lock false cacheline sharing that Christoph's
patch triggered (randomly).

A sub-sub argument was that perhaps we should not split .data and
.bss variables into separate sections - it doubles the chance of
false cacheline sharing and spreads the cacheline footprint.

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