[Suspend2][ 05/13] [Suspend2] LRU paranoia patch.

Nigel Cunningham
2006-06-27T04:45:05Z

Modify the Set/Clear LRU flag macros to also BUG_ON() when freezing is
complete, iff CONFIG_PM_DEBUG is enabled. The LRU is supposed to be static
before the atomic copy is made. This just helps verify that this is
happening.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

include/linux/page-flags.h | 8 ++++++++
1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h
index d276a4e..1e4d6a5 100644
--- a/include/linux/page-flags.h
+++ b/include/linux/page-flags.h
@@ -7,6 +7,7 @@

#include <linux/percpu.h>
#include <linux/cache.h>
+#include <linux/freezer.h> /* For Suspend2 LRU paranoid Set|ClearPageLRU definitions */
#include <asm/pgtable.h>

/*
@@ -255,9 +256,16 @@ extern void __mod_page_state_offset(unsi
#define TestClearPageDirty(page) test_and_clear_bit(PG_dirty, &(page)->flags)

#define PageLRU(page) test_bit(PG_lru, &(page)->flags)
+
+#ifdef CONFIG_PM_DEBUG
#define SetPageLRU(page) set_bit(PG_lru, &(page)->flags)
#define ClearPageLRU(page) clear_bit(PG_lru, &(page)->flags)
#define __ClearPageLRU(page) __clear_bit(PG_lru, &(page)->flags)
+#else
+#define SetPageLRU(page) do { BUG_ON(test_freezer_state(FREEZING_COMPLETE)); set_bit(PG_lru, &(page)->flags); } while(0)
+#define ClearPageLRU(page) do { BUG_ON(test_freezer_state(FREEZING_COMPLETE)); clear_bit(PG_lru, &(page)->flags); } while(0)
+#define __ClearPageLRU(page) do { BUG_ON(test_freezer_state(FREEZING_COMPLETE)); __clear_bit(PG_lru, &(page)->flags); } while(0)
+#endif

#define PageActive(page) test_bit(PG_active, &(page)->flags)
#define SetPageActive(page) set_bit(PG_active, &(page)->flags)