From: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Andi Kleen <andi@firstfloor.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
"Kirill A. Shutemov" <kirill@shutemov.name>
Subject: [PATCH v2 1/2] mm: soft-offline: clean up soft_offline_page()
Date: Tue, 12 Jan 2016 12:10:44 +0900 [thread overview]
Message-ID: <1452568245-10412-2-git-send-email-n-horiguchi@ah.jp.nec.com> (raw)
In-Reply-To: <1452568245-10412-1-git-send-email-n-horiguchi@ah.jp.nec.com>
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>
next prev parent reply other threads:[~2016-01-12 3:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` Naoya Horiguchi [this message]
2016-01-12 3:10 ` [PATCH v2 2/2] " Naoya Horiguchi
2016-01-12 23:49 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1452568245-10412-2-git-send-email-n-horiguchi@ah.jp.nec.com \
--to=n-horiguchi@ah.jp.nec.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=kirill@shutemov.name \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nao.horiguchi@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox