Skip to content

Commit 64212ec

Browse files
mitatorvalds
authored andcommitted
debug-pagealloc: add support for highmem pages
This adds support for highmem pages poisoning and verification to the debug-pagealloc feature for no-architecture support. [akpm@linux-foundation.org: remove unneeded preempt_disable/enable] Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 3ee9a4f commit 64212ec

File tree

1 file changed

+10
-34
lines changed

1 file changed

+10
-34
lines changed

mm/debug-pagealloc.c

+10-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include <linux/kernel.h>
22
#include <linux/string.h>
33
#include <linux/mm.h>
4+
#include <linux/highmem.h>
45
#include <linux/page-debug-flags.h>
56
#include <linux/poison.h>
67
#include <linux/ratelimit.h>
@@ -20,28 +21,13 @@ static inline bool page_poison(struct page *page)
2021
return test_bit(PAGE_DEBUG_FLAG_POISON, &page->debug_flags);
2122
}
2223

23-
static void poison_highpage(struct page *page)
24-
{
25-
/*
26-
* Page poisoning for highmem pages is not implemented.
27-
*
28-
* This can be called from interrupt contexts.
29-
* So we need to create a new kmap_atomic slot for this
30-
* application and it will need interrupt protection.
31-
*/
32-
}
33-
3424
static void poison_page(struct page *page)
3525
{
36-
void *addr;
26+
void *addr = kmap_atomic(page);
3727

38-
if (PageHighMem(page)) {
39-
poison_highpage(page);
40-
return;
41-
}
4228
set_page_poison(page);
43-
addr = page_address(page);
4429
memset(addr, PAGE_POISON, PAGE_SIZE);
30+
kunmap_atomic(addr);
4531
}
4632

4733
static void poison_pages(struct page *page, int n)
@@ -86,27 +72,17 @@ static void check_poison_mem(unsigned char *mem, size_t bytes)
8672
dump_stack();
8773
}
8874

89-
static void unpoison_highpage(struct page *page)
90-
{
91-
/*
92-
* See comment in poison_highpage().
93-
* Highmem pages should not be poisoned for now
94-
*/
95-
BUG_ON(page_poison(page));
96-
}
97-
9875
static void unpoison_page(struct page *page)
9976
{
100-
if (PageHighMem(page)) {
101-
unpoison_highpage(page);
77+
void *addr;
78+
79+
if (!page_poison(page))
10280
return;
103-
}
104-
if (page_poison(page)) {
105-
void *addr = page_address(page);
10681

107-
check_poison_mem(addr, PAGE_SIZE);
108-
clear_page_poison(page);
109-
}
82+
addr = kmap_atomic(page);
83+
check_poison_mem(addr, PAGE_SIZE);
84+
clear_page_poison(page);
85+
kunmap_atomic(addr);
11086
}
11187

11288
static void unpoison_pages(struct page *page, int n)

0 commit comments

Comments
 (0)