aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
authorWu Fengguang <fengguang.wu@intel.com>2009-12-16 12:19:58 +0100
committerAndi Kleen <ak@linux.intel.com>2009-12-16 12:19:58 +0100
commit8d22ba1b74aa9420b6032d856446564fb21f8090 (patch)
tree6c2e2d27e81d784faa0481500f1cecc613ff1167 /mm
parent95d01fc664b9476e0d18e3d745bb209a42a33588 (diff)
downloadkernel_samsung_aries-8d22ba1b74aa9420b6032d856446564fb21f8090.zip
kernel_samsung_aries-8d22ba1b74aa9420b6032d856446564fb21f8090.tar.gz
kernel_samsung_aries-8d22ba1b74aa9420b6032d856446564fb21f8090.tar.bz2
HWPOISON: detect free buddy pages explicitly
Most free pages in the buddy system have no PG_buddy set. Introduce is_free_buddy_page() for detecting them reliably. CC: Nick Piggin <npiggin@suse.de> CC: Mel Gorman <mel@linux.vnet.ibm.com> Signed-off-by: Wu Fengguang <fengguang.wu@intel.com> Signed-off-by: Andi Kleen <ak@linux.intel.com>
Diffstat (limited to 'mm')
-rw-r--r--mm/internal.h3
-rw-r--r--mm/memory-failure.c9
-rw-r--r--mm/page_alloc.c21
3 files changed, 31 insertions, 2 deletions
diff --git a/mm/internal.h b/mm/internal.h
index 4fe67a1..49b2ff7 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -50,6 +50,9 @@ extern void putback_lru_page(struct page *page);
*/
extern void __free_pages_bootmem(struct page *page, unsigned int order);
extern void prep_compound_page(struct page *page, unsigned long order);
+#ifdef CONFIG_MEMORY_FAILURE
+extern bool is_free_buddy_page(struct page *page);
+#endif
/*
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 676ab39..5055b94 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -807,8 +807,13 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
*/
if (!(flags & MF_COUNT_INCREASED) &&
!get_page_unless_zero(compound_head(p))) {
- action_result(pfn, "free or high order kernel", IGNORED);
- return PageBuddy(compound_head(p)) ? 0 : -EBUSY;
+ if (is_free_buddy_page(p)) {
+ action_result(pfn, "free buddy", DELAYED);
+ return 0;
+ } else {
+ action_result(pfn, "high order kernel", IGNORED);
+ return -EBUSY;
+ }
}
/*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 59d2e88..6867b4d 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -5081,3 +5081,24 @@ __offline_isolated_pages(unsigned long start_pfn, unsigned long end_pfn)
spin_unlock_irqrestore(&zone->lock, flags);
}
#endif
+
+#ifdef CONFIG_MEMORY_FAILURE
+bool is_free_buddy_page(struct page *page)
+{
+ struct zone *zone = page_zone(page);
+ unsigned long pfn = page_to_pfn(page);
+ unsigned long flags;
+ int order;
+
+ spin_lock_irqsave(&zone->lock, flags);
+ for (order = 0; order < MAX_ORDER; order++) {
+ struct page *page_head = page - (pfn & ((1 << order) - 1));
+
+ if (PageBuddy(page_head) && page_order(page_head) >= order)
+ break;
+ }
+ spin_unlock_irqrestore(&zone->lock, flags);
+
+ return order < MAX_ORDER;
+}
+#endif