Re: SL*B: drop kmem cache argument from constructor

From: Pekka Enberg
Date: Thu Jul 10 2008 - 03:13:20 EST


Hi Alexey,

[Fixing up Andrew's email address.]

On Thu, 2008-07-10 at 05:11 +0400, Alexey Dobriyan wrote:
> Kmem cache passed to constructor is only needed for constructors that are
> themselves multiplexeres. Nobody uses this "feature", nor does anybody uses
> passed kmem cache in non-trivial way, so pass only pointer to object.
>
> Non-trivial places are:
> arch/powerpc/mm/init_64.c
> arch/powerpc/mm/hugetlbpage.c
>
> This is flag day, yes.

Acked-by: Pekka Enberg <penberg@xxxxxxxxxxxxxx>

However...

> --- a/arch/powerpc/mm/hugetlbpage.c
> +++ b/arch/powerpc/mm/hugetlbpage.c
> @@ -595,9 +595,9 @@ static int __init hugepage_setup_sz(char *str)
> }
> __setup("hugepagesz=", hugepage_setup_sz);
>
> -static void zero_ctor(struct kmem_cache *cache, void *addr)
> +static void zero_ctor(void *addr)
> {
> - memset(addr, 0, kmem_cache_size(cache));
> + memset(addr, 0, HUGEPTE_TABLE_SIZE);
> }
>
> static int __init hugetlbpage_init(void)
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -136,9 +136,14 @@ static int __init setup_kcore(void)
> module_init(setup_kcore);
> #endif
>
> -static void zero_ctor(struct kmem_cache *cache, void *addr)
> +static void pgd_ctor(void *addr)
> {
> - memset(addr, 0, kmem_cache_size(cache));
> + memset(addr, 0, PGD_TABLE_SIZE);
> +}
> +
> +static void pmd_ctor(void *addr)
> +{
> + memset(addr, 0, PMD_TABLE_SIZE);
> }
>
> static const unsigned int pgtable_cache_size[2] = {
> @@ -163,19 +168,8 @@ struct kmem_cache *pgtable_cache[ARRAY_SIZE(pgtable_cache_size)];
>
> void pgtable_cache_init(void)
> {
> - int i;
> -
> - for (i = 0; i < ARRAY_SIZE(pgtable_cache_size); i++) {
> - int size = pgtable_cache_size[i];
> - const char *name = pgtable_cache_name[i];
> -
> - pr_debug("Allocating page table cache %s (#%d) "
> - "for size: %08x...\n", name, i, size);
> - pgtable_cache[i] = kmem_cache_create(name,
> - size, size,
> - SLAB_PANIC,
> - zero_ctor);
> - }
> + pgtable_cache[0] = kmem_cache_create(pgtable_cache_name[0], PGD_TABLE_SIZE, PGD_TABLE_SIZE, SLAB_PANIC, pgd_ctor);
> + pgtable_cache[1] = kmem_cache_create(pgtable_cache_name[1], PMD_TABLE_SIZE, PMD_TABLE_SIZE, SLAB_PANIC, pmd_ctor);
> }

Can we please have these hunks merged first so that the final patch
which removes the 'cache' argument from the function signature has no
functional changes?

Pekka

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