diff options
Diffstat (limited to 'mm/debug-pagealloc.c')
-rw-r--r-- | mm/debug-pagealloc.c | 45 |
1 files changed, 40 insertions, 5 deletions
diff --git a/mm/debug-pagealloc.c b/mm/debug-pagealloc.c index 789ff70c8a4a..5bf5906ce13b 100644 --- a/mm/debug-pagealloc.c +++ b/mm/debug-pagealloc.c | |||
@@ -2,23 +2,55 @@ | |||
2 | #include <linux/string.h> | 2 | #include <linux/string.h> |
3 | #include <linux/mm.h> | 3 | #include <linux/mm.h> |
4 | #include <linux/highmem.h> | 4 | #include <linux/highmem.h> |
5 | #include <linux/page-debug-flags.h> | 5 | #include <linux/page_ext.h> |
6 | #include <linux/poison.h> | 6 | #include <linux/poison.h> |
7 | #include <linux/ratelimit.h> | 7 | #include <linux/ratelimit.h> |
8 | 8 | ||
9 | static bool page_poisoning_enabled __read_mostly; | ||
10 | |||
11 | static bool need_page_poisoning(void) | ||
12 | { | ||
13 | if (!debug_pagealloc_enabled()) | ||
14 | return false; | ||
15 | |||
16 | return true; | ||
17 | } | ||
18 | |||
19 | static void init_page_poisoning(void) | ||
20 | { | ||
21 | if (!debug_pagealloc_enabled()) | ||
22 | return; | ||
23 | |||
24 | page_poisoning_enabled = true; | ||
25 | } | ||
26 | |||
27 | struct page_ext_operations page_poisoning_ops = { | ||
28 | .need = need_page_poisoning, | ||
29 | .init = init_page_poisoning, | ||
30 | }; | ||
31 | |||
9 | static inline void set_page_poison(struct page *page) | 32 | static inline void set_page_poison(struct page *page) |
10 | { | 33 | { |
11 | __set_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); | 34 | struct page_ext *page_ext; |
35 | |||
36 | page_ext = lookup_page_ext(page); | ||
37 | __set_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); | ||
12 | } | 38 | } |
13 | 39 | ||
14 | static inline void clear_page_poison(struct page *page) | 40 | static inline void clear_page_poison(struct page *page) |
15 | { | 41 | { |
16 | __clear_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); | 42 | struct page_ext *page_ext; |
43 | |||
44 | page_ext = lookup_page_ext(page); | ||
45 | __clear_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); | ||
17 | } | 46 | } |
18 | 47 | ||
19 | static inline bool page_poison(struct page *page) | 48 | static inline bool page_poison(struct page *page) |
20 | { | 49 | { |
21 | return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags); | 50 | struct page_ext *page_ext; |
51 | |||
52 | page_ext = lookup_page_ext(page); | ||
53 | return test_bit(PAGE_EXT_DEBUG_POISON, &page_ext->flags); | ||
22 | } | 54 | } |
23 | 55 | ||
24 | static void poison_page(struct page *page) | 56 | static void poison_page(struct page *page) |
@@ -93,8 +125,11 @@ static void unpoison_pages(struct page *page, int n) | |||
93 | unpoison_page(page + i); | 125 | unpoison_page(page + i); |
94 | } | 126 | } |
95 | 127 | ||
96 | void kernel_map_pages(struct page *page, int numpages, int enable) | 128 | void __kernel_map_pages(struct page *page, int numpages, int enable) |
97 | { | 129 | { |
130 | if (!page_poisoning_enabled) | ||
131 | return; | ||
132 | |||
98 | if (enable) | 133 | if (enable) |
99 | unpoison_pages(page, numpages); | 134 | unpoison_pages(page, numpages); |
100 | else | 135 | else |