[PATCH 6/7] HWPOISON: pass order to set/clear_page_hwpoison_huge_page()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When a surplus hugepage is soft-offlined, the old hugepage will
be freed into buddy directly. Then we'll have no access to hstate.
So we need to pass page order to PG_HWPoison set/clear functions.

Signed-off-by: Naoya Horiguchi <n-horiguchi@xxxxxxxxxxxxx>
---
 mm/memory-failure.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git v2.6.38-rc1/mm/memory-failure.c v2.6.38-rc1/mm/memory-failure.c
index b4910e8..eed1846 100644
--- v2.6.38-rc1/mm/memory-failure.c
+++ v2.6.38-rc1/mm/memory-failure.c
@@ -927,18 +927,18 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
 	return ret;
 }
 
-static void set_page_hwpoison_huge_page(struct page *hpage)
+static void set_page_hwpoison_huge_page(struct page *hpage, int order)
 {
 	int i;
-	int nr_pages = 1 << compound_trans_order(hpage);
+	int nr_pages = 1 << order;
 	for (i = 0; i < nr_pages; i++)
 		SetPageHWPoison(hpage + i);
 }
 
-static void clear_page_hwpoison_huge_page(struct page *hpage)
+static void clear_page_hwpoison_huge_page(struct page *hpage, int order)
 {
 	int i;
-	int nr_pages = 1 << compound_trans_order(hpage);
+	int nr_pages = 1 << order;
 	for (i = 0; i < nr_pages; i++)
 		ClearPageHWPoison(hpage + i);
 }
@@ -1002,7 +1002,8 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
 				atomic_long_sub(nr_pages, &mce_bad_pages);
 				return 0;
 			}
-			set_page_hwpoison_huge_page(hpage);
+			set_page_hwpoison_huge_page(hpage,
+						    compound_order(hpage));
 			res = dequeue_hwpoisoned_huge_page(hpage);
 			action_result(pfn, "free huge",
 				      res ? IGNORED : DELAYED);
@@ -1078,7 +1079,7 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
 	 * page lock held, we can safely set PG_hwpoison bits on tail pages.
 	 */
 	if (PageHuge(p))
-		set_page_hwpoison_huge_page(hpage);
+		set_page_hwpoison_huge_page(hpage, compound_order(hpage));
 
 	wait_on_page_writeback(p);
 
@@ -1197,7 +1198,8 @@ int unpoison_memory(unsigned long pfn)
 		atomic_long_sub(nr_pages, &mce_bad_pages);
 		freeit = 1;
 		if (PageHuge(page))
-			clear_page_hwpoison_huge_page(page);
+			clear_page_hwpoison_huge_page(page,
+						      compound_order(page));
 	}
 	unlock_page(page);
 
@@ -1275,6 +1277,7 @@ static int soft_offline_huge_page(struct page *page, int flags)
 	int ret;
 	unsigned long pfn = page_to_pfn(page);
 	struct page *hpage = compound_head(page);
+	int order = compound_order(hpage);
 	LIST_HEAD(pagelist);
 
 	ret = get_any_page(page, pfn, flags);
@@ -1303,8 +1306,8 @@ static int soft_offline_huge_page(struct page *page, int flags)
 	}
 done:
 	if (!PageHWPoison(hpage))
-		atomic_long_add(1 << compound_trans_order(hpage), &mce_bad_pages);
-	set_page_hwpoison_huge_page(hpage);
+		atomic_long_add(1 << order, &mce_bad_pages);
+	set_page_hwpoison_huge_page(hpage, order);
 	dequeue_hwpoisoned_huge_page(hpage);
 	/* keep elevated page count for bad page */
 	return ret;
-- 
1.7.3.4

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxxx  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>


[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]