From 16842709e855bb64828acda5d70ccd64fb7ee0c5 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Sat, 16 Feb 2008 09:56:26 -0800 Subject: [PATCH] slub: Var order slabs: Fix freeing of slabs Freeing of slabs assumed that slabs have maximum size. Signed-off-by: Christoph Lameter --- mm/slub.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) Index: linux-2.6/mm/slub.c =================================================================== --- linux-2.6.orig/mm/slub.c 2008-02-28 18:22:37.475963406 -0800 +++ linux-2.6/mm/slub.c 2008-02-28 18:22:40.115985165 -0800 @@ -1128,7 +1128,7 @@ out: static void __free_slab(struct kmem_cache *s, struct page *page) { - int pages = 1 << s->order; + int order = compound_order(page); if (unlikely(SlabDebug(page))) { void *p; @@ -1140,12 +1140,17 @@ static void __free_slab(struct kmem_cach ClearSlabDebug(page); } + reset_page_mapcount(page); + if (order) + /* mapcount of page + 1 was used for the object count */ + reset_page_mapcount(page + 1); + mod_zone_page_state(page_zone(page), (s->flags & SLAB_RECLAIM_ACCOUNT) ? NR_SLAB_RECLAIMABLE : NR_SLAB_UNRECLAIMABLE, - -pages); + - (1 << order)); - __free_pages(page, s->order); + __free_pages(page, order); } static void rcu_free_slab(struct rcu_head *h) @@ -1175,10 +1180,6 @@ static void discard_slab(struct kmem_cac atomic_long_dec(&n->nr_slabs); atomic_long_sub(slab_objects(s, page), &n->total_objects); - reset_page_mapcount(page); - if (PageCompound(page)) - /* mapcount of page + 1 was used for the object count */ - reset_page_mapcount(page + 1); __ClearPageSlab(page); free_slab(s, page); }