aboutsummaryrefslogtreecommitdiffstats
path: root/mm
diff options
context:
space:
mode:
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 4fe67a162cb4..49b2ff776b78 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -50,6 +50,9 @@ extern void putback_lru_page(struct page *page);
50 */ 50 */
51extern void __free_pages_bootmem(struct page *page, unsigned int order); 51extern void __free_pages_bootmem(struct page *page, unsigned int order);
52extern void prep_compound_page(struct page *page, unsigned long order); 52extern void prep_compound_page(struct page *page, unsigned long order);
53#ifdef CONFIG_MEMORY_FAILURE
54extern bool is_free_buddy_page(struct page *page);
55#endif
53 56
54 57
55/* 58/*
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 676ab394200e..5055b940df5f 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)
807 */ 807 */
808 if (!(flags & MF_COUNT_INCREASED) && 808 if (!(flags & MF_COUNT_INCREASED) &&
809 !get_page_unless_zero(compound_head(p))) { 809 !get_page_unless_zero(compound_head(p))) {
810 action_result(pfn, "free or high order kernel", IGNORED); 810 if (is_free_buddy_page(p)) {
811 return PageBuddy(compound_head(p)) ? 0 : -EBUSY; 811 action_result(pfn, "free buddy", DELAYED);
812 return 0;
813 } else {
814 action_result(pfn, "high order kernel", IGNORED);
815 return -EBUSY;
816 }
812 } 817 }
813 818
814 /* 819 /*
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 59d2e88fb47c..6867b4d391fd 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)
5081 spin_unlock_irqrestore(&zone->lock, flags); 5081 spin_unlock_irqrestore(&zone->lock, flags);
5082} 5082}
5083#endif 5083#endif
5084
5085#ifdef CONFIG_MEMORY_FAILURE
5086bool is_free_buddy_page(struct page *page)
5087{
5088 struct zone *zone = page_zone(page);
5089 unsigned long pfn = page_to_pfn(page);
5090 unsigned long flags;
5091 int order;
5092
5093 spin_lock_irqsave(&zone->lock, flags);
5094 for (order = 0; order < MAX_ORDER; order++) {
5095 struct page *page_head = page - (pfn & ((1 << order) - 1));
5096
5097 if (PageBuddy(page_head) && page_order(page_head) >= order)
5098 break;
5099 }
5100 spin_unlock_irqrestore(&zone->lock, flags);
5101
5102 return order < MAX_ORDER;
5103}
5104#endif