Suspend 2 merge: 18/51: Debug page_alloc support.

Nigel Cunningham
2004-11-24T13:30:48Z

This patch provides support for making suspend work when DEBUG_PAGEALLOC
is enabled.

diff -ruN 510-debug-pagealloc-support-old/arch/i386/mm/pageattr.c 510-debug-pagealloc-support-new/arch/i386/mm/pageattr.c
--- 510-debug-pagealloc-support-old/arch/i386/mm/pageattr.c 2004-11-03 21:53:39.000000000 +1100
+++ 510-debug-pagealloc-support-new/arch/i386/mm/pageattr.c 2004-11-04 16:27:40.000000000 +1100
@@ -211,5 +213,49 @@
EXPORT_SYMBOL(kernel_map_pages);
#endif

+#ifdef CONFIG_SOFTWARE_SUSPEND2
+#ifdef CONFIG_DEBUG_PAGEALLOC
+static int page_is_kernel_mapped(struct page * page)
+{
+ pte_t *kpte;
+ unsigned long address;
+
+#ifdef CONFIG_HIGHMEM
+ if (page >= highmem_start_page)
+ return 0;
+#endif
+
+ address = (unsigned long)page_address(page);
+
+ kpte = lookup_address(address);
+ if (!kpte)
+ return 0;
+
+ if (pte_same(*kpte, mk_pte(page, PAGE_KERNEL)))
+ return 1;
+
+ return 0;
+}
+
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+ int is_already_mapped = page_is_kernel_mapped(page);
+
+ if (enable == is_already_mapped)
+ return 1;
+
+ kernel_map_pages(page, 1, enable);
+
+ return 0;
+}
+#else
+int suspend_map_kernel_page(struct page * page, int enable)
+{
+ return (enable == 1);
+}
+#endif
+EXPORT_SYMBOL(suspend_map_kernel_page);
+#endif
+
EXPORT_SYMBOL(change_page_attr);
EXPORT_SYMBOL(global_flush_tlb);