diff options
| author | Manfred Spraul <manfred@colorfullife.com> | 2004-10-19 18:40:18 -0700 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2004-10-19 18:40:18 -0700 |
| commit | 3fe5f54e696e7af4e38fbb7ba6079dcc22875bce (patch) | |
| tree | 90deb5083483fbb68e9774ab690935f21e8fcd23 /include/linux/slab.h | |
| parent | 6902800445f4bfd224e82c7c3df74e48e925c001 (diff) | |
[PATCH] slab: reduce fragmentation due to kmem_cache_alloc_node
Attached is a patch that fixes the fragmentation that Badri noticed with
kmem_cache_alloc_node.
kmem_cache_alloc_node tries to allocate memory from a given node. The
current implementation contains two bugs:
- the node aware code was used even for !CONFIG_NUMA systems. Fix:
inline function that redefines kmem_cache_alloc_node as kmem_cache_alloc
for !CONFIG_NUMA.
- the code always allocated a new slab for each new allocation. This
caused severe fragmentation. Fix: walk the slabp lists and search for a
matching page instead of allocating a new page.
- the patch also adds a new statistics field for node-local allocs. They
should be rare - the codepath is quite slow, especially compared to the
normal kmem_cache_alloc.
Signed-Off-By: Manfred Spraul <manfred@colorfullife.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'include/linux/slab.h')
| -rw-r--r-- | include/linux/slab.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/linux/slab.h b/include/linux/slab.h index e51014cb24a0..7c81a7863b99 100644 --- a/include/linux/slab.h +++ b/include/linux/slab.h @@ -61,7 +61,14 @@ extern kmem_cache_t *kmem_cache_create(const char *, size_t, size_t, unsigned lo extern int kmem_cache_destroy(kmem_cache_t *); extern int kmem_cache_shrink(kmem_cache_t *); extern void *kmem_cache_alloc(kmem_cache_t *, int); +#ifdef CONFIG_NUMA extern void *kmem_cache_alloc_node(kmem_cache_t *, int); +#else +static inline void *kmem_cache_alloc_node(kmem_cache_t *cachep, int node) +{ + return kmem_cache_alloc(cachep, GFP_KERNEL); +} +#endif extern void kmem_cache_free(kmem_cache_t *, void *); extern unsigned int kmem_cache_size(kmem_cache_t *); |
