Re: [PATCH] modules: Use a better scheme for refcounting

From: Rusty Russell
Date: Thu May 15 2008 - 20:09:34 EST


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