Re: [PATCH] tree wide: Use kvfree() than conditional kfree()/vfree()

From: Sergey Senozhatsky
Date: Sun Nov 08 2015 - 00:32:40 EST


On (11/08/15 14:04), Tetsuo Handa wrote:
[..]
> Also, we might want to add a helper that does vmalloc() when
> kmalloc() failed because locations that do
>
> ptr = kmalloc(size, GFP_NOFS);
> if (!ptr)
> ptr = vmalloc(size); /* Wrong because GFP_KERNEL is used implicitly */
>
> are found.


ext4 does something like that.


void *ext4_kvmalloc(size_t size, gfp_t flags)
{
void *ret;

ret = kmalloc(size, flags | __GFP_NOWARN);
if (!ret)
ret = __vmalloc(size, flags, PAGE_KERNEL);
return ret;
}

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