aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/slab.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/mm/slab.c b/mm/slab.c
index bf05ea900ce8..a94cf0fea8a2 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -2499,23 +2499,28 @@ static void slab_put_obj(struct kmem_cache *cachep, struct slab *slabp,
2499 slabp->inuse--; 2499 slabp->inuse--;
2500} 2500}
2501 2501
2502static void set_slab_attr(struct kmem_cache *cachep, struct slab *slabp, 2502/*
2503 void *objp) 2503 * Map pages beginning at addr to the given cache and slab. This is required
2504 * for the slab allocator to be able to lookup the cache and slab of a
2505 * virtual address for kfree, ksize, kmem_ptr_validate, and slab debugging.
2506 */
2507static void slab_map_pages(struct kmem_cache *cache, struct slab *slab,
2508 void *addr)
2504{ 2509{
2505 int i; 2510 int nr_pages;
2506 struct page *page; 2511 struct page *page;
2507 2512
2508 /* Nasty!!!!!! I hope this is OK. */ 2513 page = virt_to_page(addr);
2509 page = virt_to_page(objp);
2510 2514
2511 i = 1; 2515 nr_pages = 1;
2512 if (likely(!PageCompound(page))) 2516 if (likely(!PageCompound(page)))
2513 i <<= cachep->gfporder; 2517 nr_pages <<= cache->gfporder;
2518
2514 do { 2519 do {
2515 page_set_cache(page, cachep); 2520 page_set_cache(page, cache);
2516 page_set_slab(page, slabp); 2521 page_set_slab(page, slab);
2517 page++; 2522 page++;
2518 } while (--i); 2523 } while (--nr_pages);
2519} 2524}
2520 2525
2521/* 2526/*
@@ -2587,7 +2592,7 @@ static int cache_grow(struct kmem_cache *cachep, gfp_t flags, int nodeid)
2587 goto opps1; 2592 goto opps1;
2588 2593
2589 slabp->nodeid = nodeid; 2594 slabp->nodeid = nodeid;
2590 set_slab_attr(cachep, slabp, objp); 2595 slab_map_pages(cachep, slabp, objp);
2591 2596
2592 cache_init_objs(cachep, slabp, ctor_flags); 2597 cache_init_objs(cachep, slabp, ctor_flags);
2593 2598