From: "Matthew Wilcox (Oracle)" <willy@infradead.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Matthew Wilcox (Oracle)" <willy@infradead.org>, linux-mm@kvack.org
Subject: [PATCH 1/3] mm: Correct page_mapped_in_vma() for large folios
Date: Thu, 28 Mar 2024 22:58:27 +0000 [thread overview]
Message-ID: <20240328225831.1765286-2-willy@infradead.org> (raw)
In-Reply-To: <20240328225831.1765286-1-willy@infradead.org>
If 'page' is the first page of a large folio then vma_address() will scan
for any page in the entire folio. This can lead to page_mapped_in_vma()
returning true if some of the tail pages are mapped and the head page
is not. This could lead to memory failure choosing to kill a task
unnecessarily.
Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
---
mm/page_vma_mapped.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/page_vma_mapped.c b/mm/page_vma_mapped.c
index 74d2de15fb5e..ac48d6284bad 100644
--- a/mm/page_vma_mapped.c
+++ b/mm/page_vma_mapped.c
@@ -325,6 +325,8 @@ bool page_vma_mapped_walk(struct page_vma_mapped_walk *pvmw)
*/
int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
{
+ struct folio *folio = page_folio(page);
+ pgoff_t pgoff = folio->index + folio_page_idx(folio, page);
struct page_vma_mapped_walk pvmw = {
.pfn = page_to_pfn(page),
.nr_pages = 1,
@@ -332,7 +334,7 @@ int page_mapped_in_vma(struct page *page, struct vm_area_struct *vma)
.flags = PVMW_SYNC,
};
- pvmw.address = vma_address(page, vma);
+ pvmw.address = vma_pgoff_address(pgoff, 1, vma);
if (pvmw.address == -EFAULT)
return 0;
if (!page_vma_mapped_walk(&pvmw))
--
2.43.0
next prev parent reply other threads:[~2024-03-28 22:58 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-28 22:58 [PATCH 0/3] Unify vma_address and vma_pgoff_address Matthew Wilcox (Oracle)
2024-03-28 22:58 ` Matthew Wilcox (Oracle) [this message]
2024-04-02 10:07 ` [PATCH 1/3] mm: Correct page_mapped_in_vma() for large folios David Hildenbrand
2024-03-28 22:58 ` [PATCH 2/3] mm: Remove vma_address() Matthew Wilcox (Oracle)
2024-03-28 22:58 ` [PATCH 3/3] mm: Rename vma_pgoff_address back to vma_address Matthew Wilcox (Oracle)
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=20240328225831.1765286-2-willy@infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=linux-mm@kvack.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).