[PATCH] slab: optimize constant-size kzalloc calls

As suggested by Eric Dumazet, optimize kzalloc() calls that pass a
compile-time constant size.  Please note that the patch increases kernel
text slightly (~200 bytes for defconfig on x86).

Signed-off-by: Pekka Enberg <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
Pekka Enberg 2006-03-25 03:06:43 -08:00 • committed by Linus Torvalds
commit 40c07ae8da
2 changed files with 30 additions and 6 deletions

View file

@ -5,18 +5,18 @@
#include <asm/uaccess.h>
/**
* kzalloc - allocate memory. The memory is set to zero.
* __kzalloc - allocate memory. The memory is set to zero.
* @size: how many bytes of memory are required.
* @flags: the type of memory to allocate.
*/
void *kzalloc(size_t size, gfp_t flags)
void *__kzalloc(size_t size, gfp_t flags)
{
void *ret = ____kmalloc(size, flags);
if (ret)
memset(ret, 0, size);
return ret;
}
EXPORT_SYMBOL(kzalloc);
EXPORT_SYMBOL(__kzalloc);
/*
* kstrdup - allocate space for and copy an existing string