Commit d8410234 authored by Joonsoo Kim's avatar Joonsoo Kim Committed by Linus Torvalds

mm/slab: factor out slab list fixup code

Slab list should be fixed up after object is detached from the slab and
this happens at two places.  They do exactly same thing.  They will be
changed in the following patch, so, to reduce code duplication, this
patch factor out them and make it common function.
Signed-off-by: default avatarJoonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: David Rientjes <rientjes@google.com>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Jesper Dangaard Brouer <brouer@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 3217fd9b
...@@ -2723,6 +2723,17 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp, ...@@ -2723,6 +2723,17 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
#define cache_free_debugcheck(x,objp,z) (objp) #define cache_free_debugcheck(x,objp,z) (objp)
#endif #endif
static inline void fixup_slab_list(struct kmem_cache *cachep,
struct kmem_cache_node *n, struct page *page)
{
/* move slabp to correct slabp list: */
list_del(&page->lru);
if (page->active == cachep->num)
list_add(&page->lru, &n->slabs_full);
else
list_add(&page->lru, &n->slabs_partial);
}
static struct page *get_first_slab(struct kmem_cache_node *n) static struct page *get_first_slab(struct kmem_cache_node *n)
{ {
struct page *page; struct page *page;
...@@ -2796,12 +2807,7 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags, ...@@ -2796,12 +2807,7 @@ static void *cache_alloc_refill(struct kmem_cache *cachep, gfp_t flags,
ac_put_obj(cachep, ac, slab_get_obj(cachep, page)); ac_put_obj(cachep, ac, slab_get_obj(cachep, page));
} }
/* move slabp to correct slabp list: */ fixup_slab_list(cachep, n, page);
list_del(&page->lru);
if (page->active == cachep->num)
list_add(&page->lru, &n->slabs_full);
else
list_add(&page->lru, &n->slabs_partial);
} }
must_grow: must_grow:
...@@ -3067,13 +3073,8 @@ static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags, ...@@ -3067,13 +3073,8 @@ static void *____cache_alloc_node(struct kmem_cache *cachep, gfp_t flags,
obj = slab_get_obj(cachep, page); obj = slab_get_obj(cachep, page);
n->free_objects--; n->free_objects--;
/* move slabp to correct slabp list: */
list_del(&page->lru);
if (page->active == cachep->num) fixup_slab_list(cachep, n, page);
list_add(&page->lru, &n->slabs_full);
else
list_add(&page->lru, &n->slabs_partial);
spin_unlock(&n->list_lock); spin_unlock(&n->list_lock);
goto done; goto done;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment