From: Naoya Horiguchi <nao.horiguchi@gmail.com>
To: linux-mm@kvack.org
Cc: Andrew Morton <akpm@linux-foundation.org>,
Michal Hocko <mhocko@kernel.org>,
Oscar Salvador <osalvador@suse.de>,
Tony Luck <tony.luck@intel.com>,
Matthew Wilcox <willy@infradead.org>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Naoya Horiguchi <naoya.horiguchi@nec.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH v1] mm, hwpoison: enable error handling on shmem thp
Date: Tue, 9 Feb 2021 15:21:28 +0900 [thread overview]
Message-ID: <20210209062128.453814-1-nao.horiguchi@gmail.com> (raw)
From: Naoya Horiguchi <naoya.horiguchi@nec.com>
Currently hwpoison code checks PageAnon() for thp and refuses to handle
errors on non-anonymous thps (just for historical reason). We now
support non-anonymou thp like shmem one, so this patch suggests to enable
to handle shmem thps. Fortunately, we already have can_split_huge_page()
to check if a give thp is splittable, so this patch relies on it.
Signed-off-by: Naoya Horiguchi <naoya.horiguchi@nec.com>
---
mm/memory-failure.c | 34 +++++++++-------------------------
1 file changed, 9 insertions(+), 25 deletions(-)
diff --git v5.11-rc6/mm/memory-failure.c v5.11-rc6_patched/mm/memory-failure.c
index e9481632fcd1..8c1575de0507 100644
--- v5.11-rc6/mm/memory-failure.c
+++ v5.11-rc6_patched/mm/memory-failure.c
@@ -956,20 +956,6 @@ static int __get_hwpoison_page(struct page *page)
{
struct page *head = compound_head(page);
- if (!PageHuge(head) && PageTransHuge(head)) {
- /*
- * Non anonymous thp exists only in allocation/free time. We
- * can't handle such a case correctly, so let's give it up.
- * This should be better than triggering BUG_ON when kernel
- * tries to touch the "partially handled" page.
- */
- if (!PageAnon(head)) {
- pr_err("Memory failure: %#lx: non anonymous thp\n",
- page_to_pfn(page));
- return 0;
- }
- }
-
if (get_page_unless_zero(head)) {
if (head == compound_head(page))
return 1;
@@ -1197,21 +1183,19 @@ static int identify_page_state(unsigned long pfn, struct page *p,
static int try_to_split_thp_page(struct page *page, const char *msg)
{
- lock_page(page);
- if (!PageAnon(page) || unlikely(split_huge_page(page))) {
- unsigned long pfn = page_to_pfn(page);
+ struct page *head;
+ lock_page(page);
+ head = compound_head(page);
+ if (PageTransHuge(head) && can_split_huge_page(head, NULL) &&
+ !split_huge_page(page)) {
unlock_page(page);
- if (!PageAnon(page))
- pr_info("%s: %#lx: non anonymous thp\n", msg, pfn);
- else
- pr_info("%s: %#lx: thp split failed\n", msg, pfn);
- put_page(page);
- return -EBUSY;
+ return 0;
}
+ pr_info("%s: %#lx: thp split failed\n", msg, page_to_pfn(page));
unlock_page(page);
-
- return 0;
+ put_page(page);
+ return -EBUSY;
}
static int memory_failure_hugetlb(unsigned long pfn, int flags)
--
2.25.1
next reply other threads:[~2021-02-09 6:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-09 6:21 Naoya Horiguchi [this message]
2021-02-09 19:46 ` [PATCH v1] mm, hwpoison: enable error handling on shmem thp Andrew Morton
2021-02-09 23:51 ` Naoya Horiguchi
2021-02-11 8:06 ` Oscar Salvador
2021-03-11 7:22 ` Hugh Dickins
2021-03-11 14:45 ` Matthew Wilcox
2021-03-11 15:14 ` HORIGUCHI NAOYA(堀口 直也)
2021-03-11 19:32 ` Jue Wang
2021-03-11 22:00 ` Hugh Dickins
2021-03-18 18:33 ` Matthew Wilcox
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=20210209062128.453814-1-nao.horiguchi@gmail.com \
--to=nao.horiguchi@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=naoya.horiguchi@nec.com \
--cc=osalvador@suse.de \
--cc=tony.luck@intel.com \
--cc=willy@infradead.org \
/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;
as well as URLs for NNTP newsgroup(s).