aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorJoonsoo Kim <iamjoonsoo.kim@lge.com>2014-08-06 19:04:27 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-06 21:01:14 -0400
commit1fe00d50a9e81150de5000490b87ed227525cf09 (patch)
treefb9390e694eb4ed8cfba463c6136d0fdf74e0da7 /mm/slab.c
parent97654dfa20caa5e6c1b0a4af715aabaf5d070d69 (diff)
slab: factor out initialization of array cache
Factor out initialization of array cache to use it in following patch. Signed-off-by: Joonsoo Kim <iamjoonsoo.kim@lge.com> Acked-by: Christoph Lameter <cl@linux.com> Cc: Pekka Enberg <penberg@kernel.org> Acked-by: David Rientjes <rientjes@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/slab.c')
-rw-r--r--mm/slab.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/mm/slab.c b/mm/slab.c
index f6ad8d335be7..8d9a0fff160d 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -791,13 +791,8 @@ static void start_cpu_timer(int cpu)
791 } 791 }
792} 792}
793 793
794static struct array_cache *alloc_arraycache(int node, int entries, 794static void init_arraycache(struct array_cache *ac, int limit, int batch)
795 int batchcount, gfp_t gfp)
796{ 795{
797 int memsize = sizeof(void *) * entries + sizeof(struct array_cache);
798 struct array_cache *nc = NULL;
799
800 nc = kmalloc_node(memsize, gfp, node);
801 /* 796 /*
802 * The array_cache structures contain pointers to free object. 797 * The array_cache structures contain pointers to free object.
803 * However, when such objects are allocated or transferred to another 798 * However, when such objects are allocated or transferred to another
@@ -805,15 +800,25 @@ static struct array_cache *alloc_arraycache(int node, int entries,
805 * valid references during a kmemleak scan. Therefore, kmemleak must 800 * valid references during a kmemleak scan. Therefore, kmemleak must
806 * not scan such objects. 801 * not scan such objects.
807 */ 802 */
808 kmemleak_no_scan(nc); 803 kmemleak_no_scan(ac);
809 if (nc) { 804 if (ac) {
810 nc->avail = 0; 805 ac->avail = 0;
811 nc->limit = entries; 806 ac->limit = limit;
812 nc->batchcount = batchcount; 807 ac->batchcount = batch;
813 nc->touched = 0; 808 ac->touched = 0;
814 spin_lock_init(&nc->lock); 809 spin_lock_init(&ac->lock);
815 } 810 }
816 return nc; 811}
812
813static struct array_cache *alloc_arraycache(int node, int entries,
814 int batchcount, gfp_t gfp)
815{
816 int memsize = sizeof(void *) * entries + sizeof(struct array_cache);
817 struct array_cache *ac = NULL;
818
819 ac = kmalloc_node(memsize, gfp, node);
820 init_arraycache(ac, entries, batchcount);
821 return ac;
817} 822}
818 823
819static inline bool is_slab_pfmemalloc(struct page *page) 824static inline bool is_slab_pfmemalloc(struct page *page)