]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blobdiff - mm/page_poison.c
Merge tag 'nfsd-4.12' of git://linux-nfs.org/~bfields/linux
[mirror_ubuntu-artful-kernel.git] / mm / page_poison.c
index 2e647c65916b91b00177837370e210d71c568f5e..be19e989ccff51f667c9698c9cb8fea3d5303f8e 100644 (file)
@@ -6,7 +6,6 @@
 #include <linux/poison.h>
 #include <linux/ratelimit.h>
 
-static bool __page_poisoning_enabled __read_mostly;
 static bool want_page_poisoning __read_mostly;
 
 static int early_page_poison_param(char *buf)
@@ -18,75 +17,22 @@ static int early_page_poison_param(char *buf)
 early_param("page_poison", early_page_poison_param);
 
 bool page_poisoning_enabled(void)
-{
-       return __page_poisoning_enabled;
-}
-
-static bool need_page_poisoning(void)
-{
-       return want_page_poisoning;
-}
-
-static void init_page_poisoning(void)
 {
        /*
-        * page poisoning is debug page alloc for some arches. If either
-        * of those options are enabled, enable poisoning
+        * Assumes that debug_pagealloc_enabled is set before
+        * free_all_bootmem.
+        * Page poisoning is debug page alloc for some arches. If
+        * either of those options are enabled, enable poisoning.
         */
-       if (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC)) {
-               if (!want_page_poisoning && !debug_pagealloc_enabled())
-                       return;
-       } else {
-               if (!want_page_poisoning)
-                       return;
-       }
-
-       __page_poisoning_enabled = true;
-}
-
-struct page_ext_operations page_poisoning_ops = {
-       .need = need_page_poisoning,
-       .init = init_page_poisoning,
-};
-
-static inline void set_page_poison(struct page *page)
-{
-       struct page_ext *page_ext;
-
-       page_ext = lookup_page_ext(page);
-       if (unlikely(!page_ext))
-               return;
-
-       __set_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags);
-}
-
-static inline void clear_page_poison(struct page *page)
-{
-       struct page_ext *page_ext;
-
-       page_ext = lookup_page_ext(page);
-       if (unlikely(!page_ext))
-               return;
-
-       __clear_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags);
-}
-
-bool page_is_poisoned(struct page *page)
-{
-       struct page_ext *page_ext;
-
-       page_ext = lookup_page_ext(page);
-       if (unlikely(!page_ext))
-               return false;
-
-       return test_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags);
+       return (want_page_poisoning ||
+               (!IS_ENABLED(CONFIG_ARCH_SUPPORTS_DEBUG_PAGEALLOC) &&
+               debug_pagealloc_enabled()));
 }
 
 static void poison_page(struct page *page)
 {
        void *addr = kmap_atomic(page);
 
-       set_page_poison(page);
        memset(addr, PAGE_POISON, PAGE_SIZE);
        kunmap_atomic(addr);
 }
@@ -140,12 +86,13 @@ static void unpoison_page(struct page *page)
 {
        void *addr;
 
-       if (!page_is_poisoned(page))
-               return;
-
        addr = kmap_atomic(page);
+       /*
+        * Page poisoning when enabled poisons each and every page
+        * that is freed to buddy. Thus no extra check is done to
+        * see if a page was posioned.
+        */
        check_poison_mem(addr, PAGE_SIZE);
-       clear_page_poison(page);
        kunmap_atomic(addr);
 }