From: Jane Chu <jane.chu@oracle.com>
To: akpm@linux-foundation.org, willy@infradead.org,
linmiaohe@huawei.com, kirill.shutemov@linux.intel.com,
hughd@google.com, linux-mm@kvack.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] mm: make page_mapped_in_vma() hugetlb walk aware
Date: Mon, 20 Jan 2025 21:18:49 -0700 [thread overview]
Message-ID: <20250121041849.3393237-1-jane.chu@oracle.com> (raw)
When a process consumes a UE in a page, the memory failure handler
attempts to collect information for a potential SIGBUS.
If the page is an anonymous page, page_mapped_in_vma(page, vma) is
invoked in order to
1. retrieve the vaddr from the process' address space,
2. verify that the vaddr is indeed mapped to the poisoned page,
where 'page' is the precise small page with UE.
It's been observed that when injecting poison to a non-head subpage
of an anonymous hugetlb page, no SIGBUS show up; while injecting to
the head page produces a SIGBUS. The casue is that, though hugetlb_walk()
returns a valid pmd entry (on x86), but check_pte() detects mismatch
between the head page per the pmd and the input subpage. Thus the vaddr
is considered not mapped to the subpage and the process is not collected
for SIGBUS purpose. This is the calling stack
collect_procs_anon
page_mapped_in_vma
page_vma_mapped_walk
hugetlb_walk
huge_pte_lock
check_pte
It seems that the most obvious place to fix the issue is by making
page_mapped_in_vma() hugetlb walk aware. The precise subpage in the
input is useful in providing PAGE_SIZE granularity vaddr.
Signed-off-by: Jane Chu <jane.chu@oracle.com>
---
mm/page_vma_mapped.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 81839a9e74f1..bc036060cc68 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -342,15 +342,26 @@ unsigned long page_mapped_in_vma(const struct page *page,
{
const struct folio *folio = page_folio(page);
struct page_vma_mapped_walk pvmw = {
- .pfn = page_to_pfn(page),
.nr_pages = 1,
.vma = vma,
.flags = PVMW_SYNC,
};
+ /* fine granularity address is always preferred */
pvmw.address = vma_address(vma, page_pgoff(folio, page), 1);
if (pvmw.address == -EFAULT)
goto out;
+
+ /*
+ * Hugetlb doesn't support partial page-mapping, hugetlb_walk()
+ * simply assumes hugetlb pte, hence feed the headpage pfn for
+ * the walk and pte check.
+ */
+ if (folio_test_hugetlb(folio))
+ pvmw.pfn = folio_pfn(folio);
+ else
+ pvmw.pfn = page_to_pfn(page);
+
if (!page_vma_mapped_walk(&pvmw))
return -EFAULT;
page_vma_mapped_walk_done(&pvmw);
--
2.39.3
next reply other threads:[~2025-01-21 4:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-21 4:18 Jane Chu [this message]
2025-01-21 5:00 ` [PATCH] mm: make page_mapped_in_vma() hugetlb walk aware Matthew Wilcox
2025-01-21 5:20 ` jane.chu
2025-02-24 20:45 ` jane.chu
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=20250121041849.3393237-1-jane.chu@oracle.com \
--to=jane.chu@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=hughd@google.com \
--cc=kirill.shutemov@linux.intel.com \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--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