* [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp @ 2016-01-08 7:24 Naoya Horiguchi 2016-01-08 20:33 ` Andrew Morton 0 siblings, 1 reply; 6+ messages in thread From: Naoya Horiguchi @ 2016-01-08 7:24 UTC (permalink / raw) To: Andrew Morton Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Naoya Horiguchi Currently memory_failure() doesn't handle non anonymous thp case, because we can hardly expect the error handling to be successful, and it can just hit some corner case which results in BUG_ON or something severe like that. This is also a case for soft offline code, so let's make it in the same way. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> --- mm/memory-failure.c | 8 +++++--- 1 files changed, 5 insertions(+), 3 deletions(-) diff --git v4.4-rc8/mm/memory-failure.c v4.4-rc8_patched/mm/memory-failure.c index 750b789..30e9085 100644 --- v4.4-rc8/mm/memory-failure.c +++ v4.4-rc8_patched/mm/memory-failure.c @@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags) return -EBUSY; } if (!PageHuge(page) && PageTransHuge(hpage)) { - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) { - pr_info("soft offline: %#lx: failed to split THP\n", - pfn); + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { + if (!PageAnon(hpage)) + pr_info("soft offline: %#lx: non anonymous thp\n", pfn); + else + pr_info("soft offline: %#lx: thp split failed\n", pfn); if (flags & MF_COUNT_INCREASED) put_hwpoison_page(page); return -EBUSY; -- 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] 6+ messages in thread
* Re: [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp 2016-01-08 7:24 [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi @ 2016-01-08 20:33 ` Andrew Morton 2016-01-12 3:10 ` Naoya Horiguchi 0 siblings, 1 reply; 6+ messages in thread From: Andrew Morton @ 2016-01-08 20:33 UTC (permalink / raw) To: Naoya Horiguchi Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Kirill A. Shutemov On Fri, 8 Jan 2016 16:24:02 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote: > Currently memory_failure() doesn't handle non anonymous thp case, because we > can hardly expect the error handling to be successful, and it can just hit > some corner case which results in BUG_ON or something severe like that. > This is also a case for soft offline code, so let's make it in the same way. > > ... > > --- v4.4-rc8/mm/memory-failure.c > +++ v4.4-rc8_patched/mm/memory-failure.c > @@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags) > return -EBUSY; > } > if (!PageHuge(page) && PageTransHuge(hpage)) { > - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) { > - pr_info("soft offline: %#lx: failed to split THP\n", > - pfn); > + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { > + if (!PageAnon(hpage)) > + pr_info("soft offline: %#lx: non anonymous thp\n", pfn); > + else > + pr_info("soft offline: %#lx: thp split failed\n", pfn); > if (flags & MF_COUNT_INCREASED) > put_hwpoison_page(page); > return -EBUSY; Kirill's http://ozlabs.org/~akpm/mmots/broken-out/thp-mm-split_huge_page-caller-need-to-lock-page.patch mucks with this code as well. Could you please redo this patch against linux-next? Thanks. -- 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] 6+ messages in thread
* Re: [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp 2016-01-08 20:33 ` Andrew Morton @ 2016-01-12 3:10 ` Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi 0 siblings, 2 replies; 6+ messages in thread From: Naoya Horiguchi @ 2016-01-12 3:10 UTC (permalink / raw) To: Andrew Morton Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Naoya Horiguchi, Kirill A. Shutemov On Fri, Jan 08, 2016 at 12:33:00PM -0800, Andrew Morton wrote: > On Fri, 8 Jan 2016 16:24:02 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote: > > > Currently memory_failure() doesn't handle non anonymous thp case, because we > > can hardly expect the error handling to be successful, and it can just hit > > some corner case which results in BUG_ON or something severe like that. > > This is also a case for soft offline code, so let's make it in the same way. > > > > ... > > > > --- v4.4-rc8/mm/memory-failure.c > > +++ v4.4-rc8_patched/mm/memory-failure.c > > @@ -1751,9 +1751,11 @@ int soft_offline_page(struct page *page, int flags) > > return -EBUSY; > > } > > if (!PageHuge(page) && PageTransHuge(hpage)) { > > - if (PageAnon(hpage) && unlikely(split_huge_page(hpage))) { > > - pr_info("soft offline: %#lx: failed to split THP\n", > > - pfn); > > + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { > > + if (!PageAnon(hpage)) > > + pr_info("soft offline: %#lx: non anonymous thp\n", pfn); > > + else > > + pr_info("soft offline: %#lx: thp split failed\n", pfn); > > if (flags & MF_COUNT_INCREASED) > > put_hwpoison_page(page); > > return -EBUSY; > > Kirill's > http://ozlabs.org/~akpm/mmots/broken-out/thp-mm-split_huge_page-caller-need-to-lock-page.patch > mucks with this code as well. Could you please redo this patch against > linux-next? OK, I did it, which will come after this email. Thanks, Naoya Horiguchi -- 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] 6+ messages in thread
* [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() 2016-01-12 3:10 ` Naoya Horiguchi @ 2016-01-12 3:10 ` Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi 1 sibling, 0 replies; 6+ messages in thread From: Naoya Horiguchi @ 2016-01-12 3:10 UTC (permalink / raw) To: Andrew Morton Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Naoya Horiguchi, Kirill A. Shutemov soft_offline_page() has some deeply indented code, that's the sign of demand for cleanup. So let's do this. No functionality change. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> --- mm/memory-failure.c | 78 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 31 deletions(-) diff --git next-20160111/mm/memory-failure.c next-20160111_patched/mm/memory-failure.c index 1b99403..2015c9a 100644 --- next-20160111/mm/memory-failure.c +++ next-20160111_patched/mm/memory-failure.c @@ -1684,6 +1684,49 @@ static int __soft_offline_page(struct page *page, int flags) return ret; } +static int soft_offline_in_use_page(struct page *page, int flags) +{ + int ret; + struct page *hpage = compound_head(page); + + if (!PageHuge(page) && PageTransHuge(hpage)) { + lock_page(hpage); + ret = split_huge_page(hpage); + unlock_page(hpage); + if (unlikely(ret || PageTransCompound(page) || + !PageAnon(page))) { + pr_info("soft offline: %#lx: failed to split THP\n", + page_to_pfn(page)); + if (flags & MF_COUNT_INCREASED) + put_hwpoison_page(hpage); + return -EBUSY; + } + get_hwpoison_page(page); + put_hwpoison_page(hpage); + } + + if (PageHuge(page)) + ret = soft_offline_huge_page(page, flags); + else + ret = __soft_offline_page(page, flags); + + return ret; +} + +static void soft_offline_free_page(struct page *page) +{ + if (PageHuge(page)) { + struct page *hpage = compound_head(page); + + set_page_hwpoison_huge_page(hpage); + if (!dequeue_hwpoisoned_huge_page(hpage)) + num_poisoned_pages_add(1 << compound_order(hpage)); + } else { + if (!TestSetPageHWPoison(page)) + num_poisoned_pages_inc(); + } +} + /** * soft_offline_page - Soft offline a page. * @page: page to offline @@ -1710,7 +1753,6 @@ int soft_offline_page(struct page *page, int flags) { int ret; unsigned long pfn = page_to_pfn(page); - struct page *hpage = compound_head(page); if (PageHWPoison(page)) { pr_info("soft offline: %#lx page already poisoned\n", pfn); @@ -1723,36 +1765,10 @@ int soft_offline_page(struct page *page, int flags) ret = get_any_page(page, pfn, flags); put_online_mems(); - if (ret > 0) { /* for in-use pages */ - if (!PageHuge(page) && PageTransHuge(hpage)) { - lock_page(hpage); - ret = split_huge_page(hpage); - unlock_page(hpage); - if (unlikely(ret || PageTransCompound(page) || - !PageAnon(page))) { - pr_info("soft offline: %#lx: failed to split THP\n", - pfn); - if (flags & MF_COUNT_INCREASED) - put_hwpoison_page(hpage); - return -EBUSY; - } - get_hwpoison_page(page); - put_hwpoison_page(hpage); - } + if (ret > 0) + ret = soft_offline_in_use_page(page, flags); + else if (ret == 0) + soft_offline_free_page(page); - if (PageHuge(page)) - ret = soft_offline_huge_page(page, flags); - else - ret = __soft_offline_page(page, flags); - } else if (ret == 0) { /* for free pages */ - if (PageHuge(page)) { - set_page_hwpoison_huge_page(hpage); - if (!dequeue_hwpoisoned_huge_page(hpage)) - num_poisoned_pages_add(1 << compound_order(hpage)); - } else { - if (!TestSetPageHWPoison(page)) - num_poisoned_pages_inc(); - } - } return ret; } -- 2.7.0 -- 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] 6+ messages in thread
* [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp 2016-01-12 3:10 ` Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() Naoya Horiguchi @ 2016-01-12 3:10 ` Naoya Horiguchi 2016-01-12 23:49 ` Andrew Morton 1 sibling, 1 reply; 6+ messages in thread From: Naoya Horiguchi @ 2016-01-12 3:10 UTC (permalink / raw) To: Andrew Morton Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Naoya Horiguchi, Kirill A. Shutemov Currently memory_failure() doesn't handle non anonymous thp case, because we can hardly expect the error handling to be successful, and it can just hit some corner case which results in BUG_ON or something severe like that. This is also the case for soft offline code, so let's make it in the same way. Orignal code has a MF_COUNT_INCREASED check before put_hwpoison_page(), but it's unnecessary because get_any_page() is already called when running on this code, which takes a refcount of the target page regardress of the flag. So this patch also removes it. Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> --- ChangeLog v1->v2: - rebased to next-20160111 --- mm/memory-failure.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git next-20160111/mm/memory-failure.c next-20160111_patched/mm/memory-failure.c index 2015c9a..6a2f290 100644 --- next-20160111/mm/memory-failure.c +++ next-20160111_patched/mm/memory-failure.c @@ -1691,16 +1691,16 @@ static int soft_offline_in_use_page(struct page *page, int flags) if (!PageHuge(page) && PageTransHuge(hpage)) { lock_page(hpage); - ret = split_huge_page(hpage); - unlock_page(hpage); - if (unlikely(ret || PageTransCompound(page) || - !PageAnon(page))) { - pr_info("soft offline: %#lx: failed to split THP\n", - page_to_pfn(page)); - if (flags & MF_COUNT_INCREASED) - put_hwpoison_page(hpage); + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { + unlock_page(hpage); + if (!PageAnon(hpage)) + pr_info("soft offline: %#lx: non anonymous thp\n", pfn); + else + pr_info("soft offline: %#lx: thp split failed\n", pfn); + put_hwpoison_page(hpage); return -EBUSY; } + unlock_page(hpage); get_hwpoison_page(page); put_hwpoison_page(hpage); } -- 2.7.0 -- 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] 6+ messages in thread
* Re: [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp 2016-01-12 3:10 ` [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi @ 2016-01-12 23:49 ` Andrew Morton 0 siblings, 0 replies; 6+ messages in thread From: Andrew Morton @ 2016-01-12 23:49 UTC (permalink / raw) To: Naoya Horiguchi Cc: Andi Kleen, linux-mm, linux-kernel, Naoya Horiguchi, Kirill A. Shutemov On Tue, 12 Jan 2016 12:10:45 +0900 Naoya Horiguchi <n-horiguchi@ah.jp.nec.com> wrote: > Currently memory_failure() doesn't handle non anonymous thp case, because we > can hardly expect the error handling to be successful, and it can just hit > some corner case which results in BUG_ON or something severe like that. > This is also the case for soft offline code, so let's make it in the same way. > > Orignal code has a MF_COUNT_INCREASED check before put_hwpoison_page(), but > it's unnecessary because get_any_page() is already called when running on > this code, which takes a refcount of the target page regardress of the flag. > So this patch also removes it. > > ... > > --- next-20160111/mm/memory-failure.c > +++ next-20160111_patched/mm/memory-failure.c > @@ -1691,16 +1691,16 @@ static int soft_offline_in_use_page(struct page *page, int flags) > > if (!PageHuge(page) && PageTransHuge(hpage)) { > lock_page(hpage); > - ret = split_huge_page(hpage); > - unlock_page(hpage); > - if (unlikely(ret || PageTransCompound(page) || > - !PageAnon(page))) { > - pr_info("soft offline: %#lx: failed to split THP\n", > - page_to_pfn(page)); > - if (flags & MF_COUNT_INCREASED) > - put_hwpoison_page(hpage); > + if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { > + unlock_page(hpage); > + if (!PageAnon(hpage)) > + pr_info("soft offline: %#lx: non anonymous thp\n", pfn); > + else > + pr_info("soft offline: %#lx: thp split failed\n", pfn); > + put_hwpoison_page(hpage); > return -EBUSY; > } hm, what happened there. mm/memory-failure.c: In function 'soft_offline_in_use_page': mm/memory-failure.c:1697: error: 'pfn' undeclared (first use in this function) mm/memory-failure.c:1697: error: (Each undeclared identifier is reported only once mm/memory-failure.c:1697: error: for each function it appears in.) --- a/mm/memory-failure.c~mm-soft-offline-exit-with-failure-for-non-anonymous-thp-fix +++ a/mm/memory-failure.c @@ -1694,9 +1694,9 @@ static int soft_offline_in_use_page(stru if (!PageAnon(hpage) || unlikely(split_huge_page(hpage))) { unlock_page(hpage); if (!PageAnon(hpage)) - pr_info("soft offline: %#lx: non anonymous thp\n", pfn); + pr_info("soft offline: %#lx: non anonymous thp\n", page_to_pfn(page)); else - pr_info("soft offline: %#lx: thp split failed\n", pfn); + pr_info("soft offline: %#lx: thp split failed\n", page_to_pfn(page)); put_hwpoison_page(hpage); return -EBUSY; } _ -- 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] 6+ messages in thread
end of thread, other threads:[~2016-01-12 23:50 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2016-01-08 7:24 [PATCH v1] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi 2016-01-08 20:33 ` Andrew Morton 2016-01-12 3:10 ` Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page() Naoya Horiguchi 2016-01-12 3:10 ` [PATCH v2 2/2] mm: soft-offline: exit with failure for non anonymous thp Naoya Horiguchi 2016-01-12 23:49 ` Andrew Morton
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).