• Manfred Spraul's avatar
    [PATCH] slab: reduce fragmentation due to kmem_cache_alloc_node · 3fe5f54e
    Manfred Spraul authored
    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: default avatarManfred Spraul <manfred@colorfullife.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    3fe5f54e
slab.c 79.7 KB