On Tuesday 15 August 2006 13:39, David Miller wrote:
> [XFRM]: Dynamic xfrm_state hash table sizing.

> +static struct hlist_head *xfrm_state_hash_alloc(unsigned int sz)
> +{
> +     struct hlist_head *n;
> +
> +     if (sz <= PAGE_SIZE)
> +             n = kmalloc(sz, GFP_KERNEL);
> +     else if (hashdist)
> +             n = __vmalloc(sz, GFP_KERNEL, PAGE_KERNEL);
> +     else
> +             n = (struct hlist_head *)
> +                     __get_free_pages(GFP_KERNEL, get_order(sz));
> +
> +     if (n)
> +             memset(n, 0, sz);
> +
> +     return n;
> +}

This kind of functions are becoming very common and duplicated... maybe we can 
factorize it ?

Also, it would be cool to be able to vmalloc()/free_pages hugetlb pages for 
very large hash tables...

> +
> +static void xfrm_state_hash_free(struct hlist_head *n, unsigned int sz)
> +{
> +     if (sz <= PAGE_SIZE)
> +             kfree(n);
> +     else if (hashdist)
> +             vfree(n);
> +     else
> +             free_pages((unsigned long)n, get_order(sz));
> +}
> +

Eric
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to