• Joonsoo Kim's avatar
    slab: change the management method of free objects of the slab · b1cb0982
    Joonsoo Kim authored
    
    
    Current free objects management method of the slab is weird, because
    it touch random position of the array of kmem_bufctl_t when we try to
    get free object. See following example.
    
    struct slab's free = 6
    kmem_bufctl_t array: 1 END 5 7 0 4 3 2
    
    To get free objects, we access this array with following pattern.
    6 -> 3 -> 7 -> 2 -> 5 -> 4 -> 0 -> 1 -> END
    
    If we have many objects, this array would be larger and be not in the same
    cache line. It is not good for performance.
    
    We can do same thing through more easy way, like as the stack.
    Only thing we have to do is to maintain stack top to free object. I use
    free field of struct slab for this purpose. After that, if we need to get
    an object, we can get it at stack top and manipulate top pointer.
    That's all. This method already used in array_cache management.
    Following is an access pattern when we use this method.
    
    struct slab's free = 0
    kmem_bufctl_t array: 6 3 7 2 5 4 0 1
    
    To get free objects, we access this array with following pattern.
    0 -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
    
    This may help cache line footprint if slab has many objects, and,
    in addition, this makes code much much simpler.
    Acked-by: default avatarAndi Kleen <ak@linux.intel.com>
    Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
    Signed-off-by: default avatarPekka Enberg <penberg@iki.fi>
    b1cb0982
slab.c 112 KB