Index: linux-2.6.16-rc6/include/linux/mm.h =================================================================== --- linux-2.6.16-rc6.orig/include/linux/mm.h 2006-03-16 19:56:48.000000000 -0800 +++ linux-2.6.16-rc6/include/linux/mm.h 2006-03-17 10:01:45.000000000 -0800 @@ -303,7 +303,7 @@ struct page { */ #define put_page_testzero(p) \ ({ \ - BUG_ON(atomic_read(&(p)->_count) == -1);\ + BUG_ON(atomic_read(&(p)->_count) < 0);\ atomic_add_negative(-1, &(p)->_count); \ }) @@ -311,10 +311,19 @@ struct page { * Grab a ref, return true if the page previously had a logical refcount of * zero. ie: returns true if we just grabbed an already-deemed-to-be-free page */ -#define get_page_testone(p) atomic_inc_and_test(&(p)->_count) +#define get_page_testone(p) \ + ({ \ + BUG_ON(atomic_read(&(p)->_count) < -1); \ + atomic_inc_and_test(&(p)->_count); \ + }) #define set_page_count(p,v) atomic_set(&(p)->_count, (v) - 1) -#define __put_page(p) atomic_dec(&(p)->_count) + +#define __put_page(p) \ + ({ \ + BUG_ON(atomic_read(&p->_count) < 0); \ + atomic_dec(&(p)->_count); \ + }) extern void FASTCALL(__page_cache_release(struct page *));