Re: [patch 03/41] cpu alloc: Use cpu allocator instead of the builtin modules per cpu allocator

From: Rusty Russell
Date: Fri May 30 2008 - 02:08:30 EST


On Friday 30 May 2008 13:56:23 Christoph Lameter wrote:
> --- linux-2.6.orig/kernel/module.c 2008-05-29 17:57:39.825214766 -0700
> +++ linux-2.6/kernel/module.c 2008-05-29 18:00:50.496815514 -0700
> @@ -314,121 +314,6 @@ static struct module *find_module(const
> return NULL;
> }

115 lines removed... This is my favourite part of the series so far :)

> if (mod->percpu)
> - percpu_modfree(mod->percpu);
> + cpu_free(mod->percpu, mod->percpu_size);

Hmm, does cpu_free(NULL, 0) do something? Seems like it shouldn't, for
symmetry with free().

> + if (align > PAGE_SIZE) {
> + printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
> + mod->name, align, PAGE_SIZE);
> + align = PAGE_SIZE;
> + }
> + percpu = cpu_alloc(size, GFP_KERNEL|__GFP_ZERO, align);
> + if (!percpu)
> + printk(KERN_WARNING "Could not allocate %lu bytes percpu data\n",
> + size);
> if (!percpu) {
> err = -ENOMEM;
> goto free_mod;

OK, we've *never* had a report of the per-cpu alignment message, so I'd be
happy to pass that through to cpu_alloc() and have it fail. Also, the if
(!percpu) cases should be combined.

> free_percpu:
> if (percpu)
> - percpu_modfree(percpu);
> + cpu_free(percpu, percpu_size);

As above.

> + goal = __per_cpu_size;

Where did __per_cpu_size come from? I missed it in the earlier patches...

Thanks,
Rusty.
--
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/