From: David Hildenbrand <david@redhat.com>
To: "Matthew Wilcox (Oracle)" <willy@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>
Cc: linux-mm@kvack.org
Subject: Re: [PATCH 1/3] mm: Correct page_mapped_in_vma() for large folios
Date: Tue, 2 Apr 2024 12:07:39 +0200 [thread overview]
Message-ID: <be5cb7d9-ee1d-43ba-9372-09f93b92e79f@redhat.com> (raw)
In-Reply-To: <20240328225831.1765286-2-willy@infradead.org>
On 28.03.24 23:58, Matthew Wilcox (Oracle) wrote:
> 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))
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Cheers,
David / dhildenb
next prev parent reply other threads:[~2024-04-02 10:07 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 ` [PATCH 1/3] mm: Correct page_mapped_in_vma() for large folios Matthew Wilcox (Oracle)
2024-04-02 10:07 ` David Hildenbrand [this message]
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=be5cb7d9-ee1d-43ba-9372-09f93b92e79f@redhat.com \
--to=david@redhat.com \
--cc=akpm@linux-foundation.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;
as well as URLs for NNTP newsgroup(s).