Re: [Bug #11342] Linux 2.6.27-rc3: kernel BUG at mm/vmalloc.c -bisected

From: Ingo Molnar
Date: Thu Sep 25 2008 - 04:56:21 EST



* Rusty Russell <rusty@xxxxxxxxxxxxxxx> wrote:

> I can't see a neater way down this path, and I don't want to lose
> const.
>
> I can see three alternatives:
> 1) An ONSTACK_CPUMASK(name) macro which declares "struct cpumask name[1]" or
> "struct cpumask *name". Same idea as yours, without the typedef.
> 2) Use a normal struct for cpumask, make everyone use pointers, but have an
> struct cpumask *alloc_stack_cpumask() which uses alloca() for small
> NR_CPUS.
> 3) Same, but just use kmalloc everywhere. Optimize important cases by hand.
>
> Anyone see a better way?

since most of the important cpumasks in high-perf codepaths are already
pre-constructed and embedded in some existing object (say task_struct),
i think a variant of #3 is the best approach:

- get rid of cpumask_t and use 'struct cpumask' everywhere.

- do not expose normal kernel code to struct cpumask's definition, only
declare the type via 'struct cpumask;' in sched.h - a'la
kmem_cache_t.

- even hide the structure from sched.h - use an extra indirection for
struct cpumask *cpus_allowed in task_struct and be done with it.

- have normal cpumask object alloc/free codepaths.

- optimize any remaining important cases by hand, if needed. (the
scheduler mostly)

(wrt. #2, alloca() is a nightmare i think.)

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/