Index: linux-2.6/include/linux/mm.h =================================================================== --- linux-2.6.orig/include/linux/mm.h +++ linux-2.6/include/linux/mm.h @@ -15,6 +15,7 @@ #include #include #include +#include struct mempolicy; struct anon_vma; @@ -264,6 +265,8 @@ struct page { void *virtual; /* Kernel virtual address (NULL if not kmapped, ie. highmem) */ #endif /* WANT_PAGE_VIRTUAL */ + + void *debug; }; #define page_private(page) ((page)->private) @@ -294,8 +297,14 @@ struct page { */ static inline int put_page_testzero(struct page *page) { - BUG_ON(atomic_read(&page->_count) == 0); - return atomic_dec_and_test(&page->_count); + if (unlikely(atomic_read(&page->_count) == 0)) { + printk(KERN_WARNING "put_page_testzero found free page (flags = %lx)\n", page->flags); + if (page->debug) + print_symbol(KERN_WARNING "nopage is %s\n", (unsigned long)page->debug); + WARN_ON(1); + return 0; + } else + return atomic_dec_and_test(&page->_count); } /* Index: linux-2.6/mm/memory.c =================================================================== --- linux-2.6.orig/mm/memory.c +++ linux-2.6/mm/memory.c @@ -2056,6 +2056,8 @@ retry: if (new_page == NOPAGE_OOM) return VM_FAULT_OOM; + new_page->debug = (struct address_space *)vma->vm_ops->nopage; + /* * Should we do an early C-O-W break? */ Index: linux-2.6/mm/page_alloc.c =================================================================== --- linux-2.6.orig/mm/page_alloc.c +++ linux-2.6/mm/page_alloc.c @@ -521,6 +521,8 @@ static int prep_new_page(struct page *pa if (PageReserved(page)) return 1; + page->debug = NULL; + page->flags &= ~(1 << PG_uptodate | 1 << PG_error | 1 << PG_referenced | 1 << PG_arch_1 | 1 << PG_checked | 1 << PG_mappedtodisk);