]> git.hungrycats.org Git - linux/commitdiff
[PATCH] more slab page checking
authorAndrew Morton <akpm@osdl.org>
Wed, 3 Sep 2003 18:12:33 +0000 (11:12 -0700)
committerLinus Torvalds <torvalds@home.osdl.org>
Wed, 3 Sep 2003 18:12:33 +0000 (11:12 -0700)
Add checks for kfree() of a page which was allocated with __alloc_pages(),
and for free_pages() of a page which was allocated with kmalloc().

include/linux/page-flags.h
mm/page_alloc.c
mm/slab.c

index d4fd6bb3ca43135f0270cd5f2443a0f873681d44..006fde0295d54a1a5c3df17289e4b7aeeedb5eff 100644 (file)
@@ -191,6 +191,8 @@ extern void get_full_page_state(struct page_state *ret);
 #define PageSlab(page)         test_bit(PG_slab, &(page)->flags)
 #define SetPageSlab(page)      set_bit(PG_slab, &(page)->flags)
 #define ClearPageSlab(page)    clear_bit(PG_slab, &(page)->flags)
+#define TestClearPageSlab(page)        test_and_clear_bit(PG_slab, &(page)->flags)
+#define TestSetPageSlab(page)  test_and_set_bit(PG_slab, &(page)->flags)
 
 #ifdef CONFIG_HIGHMEM
 #define PageHighMem(page)      test_bit(PG_highmem, &(page)->flags)
index 453f291437ab6a4b52cc596f12e07710c885100e..2ac25b6c141f0430531865ae0543a824db22e04a 100644 (file)
@@ -220,6 +220,7 @@ static inline void free_pages_check(const char *function, struct page *page)
                        1 << PG_locked  |
                        1 << PG_active  |
                        1 << PG_reclaim |
+                       1 << PG_slab    |
                        1 << PG_writeback )))
                bad_page(function, page);
        if (PageDirty(page))
index 6093193d0456f0775cc185b13b177a513603f198..f54d4e83c7f3c5b2e1cdbe101bc958397e79ecf7 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -787,7 +787,8 @@ static inline void kmem_freepages (kmem_cache_t *cachep, void *addr)
         * vm_scan(). Shouldn't be a worry.
         */
        while (i--) {
-               ClearPageSlab(page);
+               if (!TestClearPageSlab(page))
+                       BUG();
                page++;
        }
        sub_page_state(nr_slab, nr_freed);