On Wed, 28 Jul 2010 17:56:23 +0100 Steven Whitehouse <swhit...@redhat.com> 
wrote:

> +static void *gfs2_alloc_sort_buffer(unsigned size)
> +{
> +     void *ptr = NULL;
> +
> +     if (size < KMALLOC_MAX_SIZE)
> +             ptr = kmalloc(size, GFP_NOFS | __GFP_NOWARN);
> +     if (!ptr)
> +             ptr = __vmalloc(size, GFP_NOFS, PAGE_KERNEL);
> +     return ptr;
> +}
> +
> +static void gfs2_free_sort_buffer(void *ptr)
> +{
> +     if (is_vmalloc_addr(ptr))
> +             vfree(ptr);
> +     else
> +             kfree(ptr);
> +}

This got kicked around a bit in May (Subject: mm: generic adaptive
large memory allocation APIs).  That patch tried kmalloc(), then
alloc_pages(), then vmalloc().  Nothing got merged though.

I wasn't terribly excited about it because of vague fears that it would
just incite people to spend even less effort thinking about how large
their individual allocations are.

apparmor has a private kvfree/kvmalloc.  Probably there are other
versions floating around the tree as well.

Reply via email to