Index: linux-2.6.21-rc5-mm4/mm/slub.c =================================================================== --- linux-2.6.21-rc5-mm4.orig/mm/slub.c 2007-04-06 10:33:13.000000000 -0700 +++ linux-2.6.21-rc5-mm4/mm/slub.c 2007-04-06 10:36:45.000000000 -0700 @@ -572,6 +572,28 @@ static int on_freelist(struct kmem_cache return 0; } +/* + * Tracking of fully allocated slabs for debugging + */ +static void add_full(struct kmem_cache *s, struct page *page) +{ + struct kmem_cache_node *n = get_node(s, page_to_nid(page)); + + spin_lock(&n->list_lock); + list_add(&page->lru, &n->full); + spin_unlock(&n->list_lock); +} + +static void remove_full(struct kmem_cache *s, + struct page *page) +{ + struct kmem_cache_node *n = get_node(s, page_to_nid(page)); + + spin_lock(&n->list_lock); + list_del(&page->lru); + spin_unlock(&n->list_lock); +} + static int alloc_object_checks(struct kmem_cache *s, struct page *page, void *object) { @@ -862,7 +884,7 @@ static void add_partial(struct kmem_cach spin_lock(&n->list_lock); n->nr_partial++; - list_add_tail(&page->lru, &n->partial); + list_add(&page->lru, &n->partial); spin_unlock(&n->list_lock); } @@ -1187,6 +1209,9 @@ debug: goto another_slab; if (s->flags & SLAB_STORE_USER) set_tracking(s, object, 0); + if (get_freepointer(s, object)) + /* Slab will be full */ + add_full(s, page); goto have_object; } @@ -1264,6 +1289,9 @@ slab_empty: debug: if (free_object_checks(s, page, x)) goto checks_ok; + /* Debugging means we keep lists of full slabs */ + if (!page->freelist) + remove_full(s, page); goto out_unlock; } @@ -1384,6 +1412,7 @@ static void init_kmem_cache_node(struct atomic_long_set(&n->nr_slabs, 0); spin_lock_init(&n->list_lock); INIT_LIST_HEAD(&n->partial); + INIT_LIST_HEAD(&n->full); } static void free_kmem_cache_nodes(struct kmem_cache *s) Index: linux-2.6.21-rc5-mm4/include/linux/slub_def.h =================================================================== --- linux-2.6.21-rc5-mm4.orig/include/linux/slub_def.h 2007-04-03 23:48:34.000000000 -0700 +++ linux-2.6.21-rc5-mm4/include/linux/slub_def.h 2007-04-06 10:36:45.000000000 -0700 @@ -16,6 +16,7 @@ struct kmem_cache_node { unsigned long nr_partial; atomic_long_t nr_slabs; struct list_head partial; + struct list_head full; }; /*