From 91513808467b334532f38462ee587ecde2bba3f7 Mon Sep 17 00:00:00 2001 From: Christoph Lameter Date: Fri, 15 Feb 2008 15:22:21 -0800 Subject: [PATCH] slub: for_each_object must be passed the number of objects in a slab Pass the number of objects to the for_each_object macro. Reviewed-by: Pekka Enberg Signed-off-by: Christoph Lameter --- mm/slub.c | 21 ++++++++++++--------- 1 files changed, 12 insertions(+), 9 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index f8c24de..0ade0af 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -334,8 +334,8 @@ static inline void set_freepointer(struct kmem_cache *s, void *object, void *fp) } /* Loop over all objects in a slab */ -#define for_each_object(__p, __s, __addr) \ - for (__p = (__addr); __p < (__addr) + (__s)->objects * (__s)->size;\ +#define for_each_object(__p, __s, __addr, __objects) \ + for (__p = (__addr); __p < (__addr) + (__objects) * (__s)->size;\ __p += (__s)->size) /* Scan freelist */ @@ -1101,7 +1101,7 @@ static struct page *new_slab(struct kmem_cache *s, gfp_t flags, int node) memset(start, POISON_INUSE, PAGE_SIZE << s->order); last = start; - for_each_object(p, s, start) { + for_each_object(p, s, start, slab_objects(s, page)) { setup_object(s, page, last); set_freepointer(s, last, p); last = p; @@ -1123,7 +1123,8 @@ static void __free_slab(struct kmem_cache *s, struct page *page) void *p; slab_pad_check(s, page); - for_each_object(p, s, page_address(page)) + for_each_object(p, s, page_address(page), + slab_objects(s, page)) check_object(s, page, p, 0); ClearSlabDebug(page); } @@ -3184,13 +3185,14 @@ static int validate_slab(struct kmem_cache *s, struct page *page, { void *p; void *addr = page_address(page); + unsigned long objects = slab_objects(s, page); if (!check_slab(s, page) || !on_freelist(s, page, NULL)) return 0; /* Now we know that a valid freelist exists */ - bitmap_zero(map, s->objects); + bitmap_zero(map, objects); for_each_free_object(p, s, page->freelist) { set_bit(slab_index(p, s, addr), map); @@ -3198,7 +3200,7 @@ static int validate_slab(struct kmem_cache *s, struct page *page, return 0; } - for_each_object(p, s, addr) + for_each_object(p, s, addr, objects) if (!test_bit(slab_index(p, s, addr), map)) if (!check_object(s, page, p, 1)) return 0; @@ -3467,14 +3469,15 @@ static void process_slab(struct loc_track *t, struct kmem_cache *s, struct page *page, enum track_item alloc) { void *addr = page_address(page); - DECLARE_BITMAP(map, s->objects); + unsigned long objects = slab_objects(s, page); + DECLARE_BITMAP(map, objects); void *p; - bitmap_zero(map, s->objects); + bitmap_zero(map, objects); for_each_free_object(p, s, page->freelist) set_bit(slab_index(p, s, addr), map); - for_each_object(p, s, addr) + for_each_object(p, s, addr, objects) if (!test_bit(slab_index(p, s, addr), map)) add_location(t, s, get_track(s, p, alloc)); } -- 1.5.4.1