Skip to content

Commit

Permalink
slab: factor out initialization of array cache
Browse files Browse the repository at this point in the history
Factor out initialization of array cache to use it in following patch.

Signed-off-by: Joonsoo Kim <[email protected]>
Acked-by: Christoph Lameter <[email protected]>
Cc: Pekka Enberg <[email protected]>
Acked-by: David Rientjes <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
JoonsooKim authored and torvalds committed Aug 7, 2014
1 parent 97654df commit 1fe00d5
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions mm/slab.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,29 +791,34 @@ static void start_cpu_timer(int cpu)
}
}

static struct array_cache *alloc_arraycache(int node, int entries,
int batchcount, gfp_t gfp)
static void init_arraycache(struct array_cache *ac, int limit, int batch)
{
int memsize = sizeof(void *) * entries + sizeof(struct array_cache);
struct array_cache *nc = NULL;

nc = kmalloc_node(memsize, gfp, node);
/*
* The array_cache structures contain pointers to free object.
* However, when such objects are allocated or transferred to another
* cache the pointers are not cleared and they could be counted as
* valid references during a kmemleak scan. Therefore, kmemleak must
* not scan such objects.
*/
kmemleak_no_scan(nc);
if (nc) {
nc->avail = 0;
nc->limit = entries;
nc->batchcount = batchcount;
nc->touched = 0;
spin_lock_init(&nc->lock);
kmemleak_no_scan(ac);
if (ac) {
ac->avail = 0;
ac->limit = limit;
ac->batchcount = batch;
ac->touched = 0;
spin_lock_init(&ac->lock);
}
return nc;
}

static struct array_cache *alloc_arraycache(int node, int entries,
int batchcount, gfp_t gfp)
{
int memsize = sizeof(void *) * entries + sizeof(struct array_cache);
struct array_cache *ac = NULL;

ac = kmalloc_node(memsize, gfp, node);
init_arraycache(ac, entries, batchcount);
return ac;
}

static inline bool is_slab_pfmemalloc(struct page *page)
Expand Down

0 comments on commit 1fe00d5

Please sign in to comment.