aboutsummaryrefslogtreecommitdiffstats
path: root/mm/slab.c
diff options
context:
space:
mode:
authorChristoph Lameter <clameter@sgi.com>2007-05-06 17:49:41 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-07 15:12:54 -0400
commitb49af68ff9fc5d6e0d96704a1843968b91cc73c6 (patch)
treeeb5e6d9425a9069cdfc45b09a1d0f61f1419d2c2 /mm/slab.c
parent6d7779538f765963ced45a3fa4bed7ba8d2c277d (diff)
Add virt_to_head_page and consolidate code in slab and slub
Signed-off-by: Christoph Lameter <clameter@sgi.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.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/mm/slab.c b/mm/slab.c
index f4b2e22b5c61..3e984afc199c 100644
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -614,20 +614,19 @@ static inline void page_set_slab(struct page *page, struct slab *slab)
614 614
615static inline struct slab *page_get_slab(struct page *page) 615static inline struct slab *page_get_slab(struct page *page)
616{ 616{
617 page = compound_head(page);
618 BUG_ON(!PageSlab(page)); 617 BUG_ON(!PageSlab(page));
619 return (struct slab *)page->lru.prev; 618 return (struct slab *)page->lru.prev;
620} 619}
621 620
622static inline struct kmem_cache *virt_to_cache(const void *obj) 621static inline struct kmem_cache *virt_to_cache(const void *obj)
623{ 622{
624 struct page *page = virt_to_page(obj); 623 struct page *page = virt_to_head_page(obj);
625 return page_get_cache(page); 624 return page_get_cache(page);
626} 625}
627 626
628static inline struct slab *virt_to_slab(const void *obj) 627static inline struct slab *virt_to_slab(const void *obj)
629{ 628{
630 struct page *page = virt_to_page(obj); 629 struct page *page = virt_to_head_page(obj);
631 return page_get_slab(page); 630 return page_get_slab(page);
632} 631}
633 632
@@ -2876,7 +2875,7 @@ static void *cache_free_debugcheck(struct kmem_cache *cachep, void *objp,
2876 2875
2877 objp -= obj_offset(cachep); 2876 objp -= obj_offset(cachep);
2878 kfree_debugcheck(objp); 2877 kfree_debugcheck(objp);
2879 page = virt_to_page(objp); 2878 page = virt_to_head_page(objp);
2880 2879
2881 slabp = page_get_slab(page); 2880 slabp = page_get_slab(page);
2882 2881
@@ -3100,7 +3099,7 @@ static void *cache_alloc_debugcheck_after(struct kmem_cache *cachep,
3100 struct slab *slabp; 3099 struct slab *slabp;
3101 unsigned objnr; 3100 unsigned objnr;
3102 3101
3103 slabp = page_get_slab(virt_to_page(objp)); 3102 slabp = page_get_slab(virt_to_head_page(objp));
3104 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size; 3103 objnr = (unsigned)(objp - slabp->s_mem) / cachep->buffer_size;
3105 slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE; 3104 slab_bufctl(slabp)[objnr] = BUFCTL_ACTIVE;
3106 } 3105 }