Messages in this thread |  | | | From | Rusty Russell <> | | Subject | Re: [PATCH] modules: Use a better scheme for refcounting | | Date | Fri, 16 May 2008 10:09:11 +1000 | |
On Friday 16 May 2008 06:40:37 Eric Dumazet wrote:
> Current refcounting for modules (done if CONFIG_MODULE_UNLOAD=y)
> is using a lot of memory.
Hi Eric,
I like this patch! The plan was always to create a proper dynamic per-cpu
allocator which used the normal per-cpu offsets, but I think module refcounts
are worthwhile as a special case.
Any chance I can ask you look at the issue of full dynamic per-cpu
allocation? The problem of allocating memory which is laid out precisely
as the original per-cpu alloc is vexing on NUMA, and probably requires
reserving virtual address space and remapping into it, but the rewards
would be maximally-efficient per-cpu accessors, and getting rid of that
boutique allocator in module.c.
Only minor commentry on the patch itself:
> +#ifdef CONFIG_SMP
> + char *refptr;
> +#else
void * would seem more natural here (love those gcc'isms)
> +#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
> + void *refptr = NULL;
> +#endif
Looks like you can skip this if you assign to mod->refptr directly below:
> +#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
> + refptr = percpu_modalloc(sizeof(local_t), sizeof(local_t), mod->name);
> + if (!refptr)
> + goto free_mod;
> + mod->refptr = refptr;
> +#endif
And finally:
> +#if defined(CONFIG_MODULE_UNLOAD) && defined(CONFIG_SMP)
> + if (refptr)
> + percpu_modfree(refptr);
> +#endif
This if (refptr) seems redundant.
Thanks!
Rusty.
|  |