linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm: fix huge page reallocated in soft_offline_page
@ 2013-12-16  9:00 Xishi Qiu
  2013-12-16  9:41 ` Xishi Qiu
  0 siblings, 1 reply; 2+ messages in thread
From: Xishi Qiu @ 2013-12-16  9:00 UTC (permalink / raw)
  To: Andi Kleen, Andrew Morton, WuJianguo; +Cc: Xishi Qiu, Linux MM, LKML

The huge page may be reallocated in soft_offline_page, because
MIGRATE_ISOLATE can not keep the page until after setting PG_hwpoison.
alloc_huge_page()
	dequeue_huge_page_vma()
		dequeue_huge_page_node()
If the huge page was reallocated, we need to try offline it again.

Signed-off-by: Xishi Qiu <qiuxishi@huawei.com>
---
 mm/memory-failure.c |   21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index b7c1716..f384249 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1505,8 +1505,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
 		if (ret > 0)
 			ret = -EIO;
 	} else {
+		ret = dequeue_hwpoisoned_huge_page(hpage);
+		/* If the page was reallocated, we need to try again. */
+		if (ret)
+			return -EAGAIN;
 		set_page_hwpoison_huge_page(hpage);
-		dequeue_hwpoisoned_huge_page(hpage);
 		atomic_long_add(1 << compound_order(hpage),
 				&num_poisoned_pages);
 	}
@@ -1624,10 +1627,11 @@ static int __soft_offline_page(struct page *page, int flags)
  */
 int soft_offline_page(struct page *page, int flags)
 {
-	int ret;
+	int ret, retry_max = 3;
 	unsigned long pfn = page_to_pfn(page);
 	struct page *hpage = compound_trans_head(page);
 
+retry:
 	if (PageHWPoison(page)) {
 		pr_info("soft offline: %#lx page already poisoned\n", pfn);
 		return -EBUSY;
@@ -1663,8 +1667,15 @@ int soft_offline_page(struct page *page, int flags)
 			ret = __soft_offline_page(page, flags);
 	} else if (ret == 0) { /* for free pages */
 		if (PageHuge(page)) {
+			ret = dequeue_hwpoisoned_huge_page(hpage);
+			/* If the page was reallocated, we need to try again. */
+			if (ret) {
+				unset_migratetype_isolate(page,
+						MIGRATE_MOVABLE);
+				if (retry_max-- > 0)
+					goto retry;
+			}
 			set_page_hwpoison_huge_page(hpage);
-			dequeue_hwpoisoned_huge_page(hpage);
 			atomic_long_add(1 << compound_order(hpage),
 					&num_poisoned_pages);
 		} else {
@@ -1673,5 +1684,9 @@ int soft_offline_page(struct page *page, int flags)
 		}
 	}
 	unset_migratetype_isolate(page, MIGRATE_MOVABLE);
+
+	if (ret == -EAGAIN && retry_max-- > 0)
+		goto retry;
+
 	return ret;
 }
-- 
1.7.1


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] mm: fix huge page reallocated in soft_offline_page
  2013-12-16  9:00 [PATCH] mm: fix huge page reallocated in soft_offline_page Xishi Qiu
@ 2013-12-16  9:41 ` Xishi Qiu
  0 siblings, 0 replies; 2+ messages in thread
From: Xishi Qiu @ 2013-12-16  9:41 UTC (permalink / raw)
  To: Xishi Qiu; +Cc: Andi Kleen, Andrew Morton, WuJianguo, Linux MM, LKML

On 2013/12/16 17:00, Xishi Qiu wrote:

> The huge page may be reallocated in soft_offline_page, because
> MIGRATE_ISOLATE can not keep the page until after setting PG_hwpoison.
> alloc_huge_page()
> 	dequeue_huge_page_vma()
> 		dequeue_huge_page_node()
> If the huge page was reallocated, we need to try offline it again.
> 

Sorry, I made a mistake.
This bug was fixed in
commit c8721bbbdd36382de51cd6b7a56322e0acca2414

Thanks,
Xishi Qiu

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-12-16  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-16  9:00 [PATCH] mm: fix huge page reallocated in soft_offline_page Xishi Qiu
2013-12-16  9:41 ` Xishi Qiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).