From: sashiko-bot@kernel.org
To: "Yeoreum Yun" <yeoreum.yun@arm.com>,
"Jason Gunthorpe" <jgg@ziepe.ca>,
"John Hubbard" <jhubbard@nvidia.com>,
"Peter Xu" <peterx@redhat.com>,
linux-mm@kvack.org, "Jan Kara" <jack@suse.cz>,
"Josef Bacik" <josef@toxicpanda.com>,
"Johannes Weiner" <hannes@cmpxchg.org>,
"Lorenzo Stoakes" <ljs@kernel.org>,
"Liam R. Howlett" <liam@infradead.org>,
"Vlastimil Babka" <vbabka@kernel.org>,
"Mike Rapoport" <rppt@kernel.org>,
"Suren Baghdasaryan" <surenb@google.com>,
"Michal Hocko" <mhocko@suse.com>, "Jann Horn" <jannh@google.com>,
"Pedro Falcato" <pfalcato@suse.de>
Cc: "David Hildenbrand" <david@kernel.org>,
"Andrew Morton" <akpm@linux-foundation.org>,
"Harrison Crosse" <harrison@crosse.dev>
Subject: Re: [PATCH 1/3] mm: gup: handle fault retries in __mm_populate()
Date: Fri, 04 Dec 2026 15:17:50 +0000 [thread overview]
Message-ID: <sashiko-outbox-250079@kernel.org> (raw)
In-Reply-To: <20261203-infinite_mm_populate-v1-1-da5f1bccb3a2@arm.com>
Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] mm: missing Signed-off-by trailer for Co-developed-by co-author
- [Medium] mm: stale tried flag in __mm_populate() leaks FOLL_TRIED to
next VMA
- [Medium] mm: __mm_populate() flushes LRU batches after every 1-page
retry
- [Low] mm: missing kernel-doc for retry param in
__populate_vma_page_range()
--
commit d410414cbb98de6eb94b0fba36ff0f79882dcf4e
Author: Yeoreum Yun <yeoreum.yun@arm.com>
> mm: gup: handle fault retries in __mm_populate()
>
> When populating a file mapping whose reads repeatedly fail,
> __mm_populate() can retry the same page indefinitely.
>
> On the first fault, filemap_fault() may drop mmap_lock before reading
> the page and return VM_FAULT_RETRY without reporting the read error.
> __get_user_pages() then returns the number of pages processed, which
> may be zero. However, __mm_populate() retries the faulting page without
> FOLL_TRIED, allowing this sequence to repeat indefinitely.
>
> To address this, track whether __get_user_pages() dropped mmap_lock
> After reacquiring the lock and looking up the VMA again, retry a single
> page with FOLL_TRIED.
>
> Fixes: 6b4c9f446981 ("filemap: drop the mmap_sem for all blocking operations")
> Co-developed-by: Harrison Crosse <harrison@crosse.dev>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
[Severity: High]
Co-developed-by: Harrison Crosse <harrison@crosse.dev> is missing a
matching Signed-off-by trailer. Per
Documentation/process/submitting-patches.rst, every Co-developed-by tag
must be immediately followed by a Signed-off-by from that co-author.
> diff --git a/mm/gup.c b/mm/gup.c
> index ec0bc99202169..d2ff0b667e377 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1886,7 +1886,7 @@ static __always_inline long __get_user_pages_locked(struct mm_struct *mm,
> }
>
> /**
> - * populate_vma_page_range() - populate a range of pages in the vma.
> + * __populate_vma_page_range() - populate a range of pages in the vma.
> * @vma: target vma
> * @start: start address
> * @end: end address
> @@ -1905,8 +1905,8 @@ static __always_inline long __get_user_pages_locked(struct mm_struct *mm,
> * If @locked is non-NULL, it must held for read only and may be
> * released. If it's released, *@locked will be set to 0.
> */
> -long populate_vma_page_range(struct vm_area_struct *vma,
> - unsigned long start, unsigned long end, int *locked)
> +static long __populate_vma_page_range(struct vm_area_struct *vma,
> + unsigned long start, unsigned long end, int *locked, bool retry)
> {
[Severity: Low]
The kernel-doc comment for __populate_vma_page_range() does not document
the new @retry parameter, which triggers a warning under make W=1 /
scripts/kernel-doc.
[ ... ]
> @@ -2058,8 +2069,14 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
> * Now fault in a range of pages. populate_vma_page_range()
> * double checks the vma flags, so that it won't mlock pages
> * if the vma was already munlocked.
> + *
> + * If we dropped the mmap_lock due to VM_FAULT_RETRY, retry only
> + * the faulting page with FOLL_TRIED, so the fault handler
> + * reports errors instead of making us retry forever.
> */
> - ret = populate_vma_page_range(vma, nstart, nend, &locked);
> + populate_end = (tried) ? nstart + PAGE_SIZE : nend;
> + ret = __populate_vma_page_range(vma, nstart, populate_end, &locked, tried);
> + tried = !locked;
> if (ret < 0) {
> if (ignore_errors) {
> ret = 0;
[Severity: Medium]
Can tried stay true when __mm_populate() moves on to a different address
or VMA?
After __populate_vma_page_range() drops mmap_read_lock, another thread
can unmap the faulting VMA or replace it with a VM_IO/VM_PFNMAP VMA. On
the next iteration, __mm_populate() advances past the faulting address
without clearing tried:
mm/gup.c:__mm_populate() {
...
if (vma_test_any(vma, VMA_IO_BIT, VMA_PFNMAP_BIT))
continue;
if (nstart < vma->vm_start)
nstart = vma->vm_start;
...
}
The first fault on the next VMA then runs with FOLL_TRIED
(FAULT_FLAG_TRIED), so maybe_unlock_mmap_for_io() keeps mmap_read_lock
held across blocking file I/O and mm_account_fault() accounts it as a
major fault. Resetting tried = false in both branches would avoid
leaking retry state across addresses.
[Severity: Medium]
Does clamping the retry to a single page cause a performance regression
by flushing LRU batches after every 1-page retry?
__populate_vma_page_range() unconditionally calls lru_add_drain() before
returning. The next iteration then re-enters __populate_vma_page_range()
for [nstart + PAGE_SIZE, nend) under the same mmap_read_lock, repeating
gup_vma_lookup().
During mlock() on swapped-out memory or MAP_POPULATE on a writable
MAP_PRIVATE mapping, the 1-page retry queues one folio into mlock_fbatch
or cpu_fbatches.lru_add, and lru_add_drain() immediately takes
lruvec->lru_lock with IRQs disabled to flush it instead of batching.
Hoisting lru_add_drain() out of __populate_vma_page_range() to
populate_vma_page_range() and once at the end of __mm_populate(),
matching faultin_page_range(), would avoid draining 1-folio batches on
retries.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261203-infinite_mm_populate-v1-0-da5f1bccb3a2@arm.com?part=1
next prev parent reply other threads:[~2026-12-04 15:17 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-03 15:17 [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Yeoreum Yun
2026-12-03 15:17 ` [PATCH 1/3] " Yeoreum Yun
2026-12-04 3:23 ` Liam R. Howlett
2026-12-04 8:30 ` Yeoreum Yun
2026-12-04 5:29 ` kernel test robot
2026-12-04 15:17 ` sashiko-bot [this message]
2026-12-03 15:17 ` [PATCH 2/3] mm: gup: remove unused argument in populate_vma_page_range() Yeoreum Yun
2026-12-04 3:28 ` Liam R. Howlett
2026-12-04 8:41 ` Yeoreum Yun
2026-12-04 15:17 ` sashiko-bot
2026-12-03 15:17 ` [PATCH 3/3] mm: gup: make mmap_lock acquisition in __mm_populate() killable Yeoreum Yun
2026-12-04 3:35 ` Liam R. Howlett
2026-12-04 8:38 ` Yeoreum Yun
2026-12-04 3:23 ` [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Liam R. Howlett
2026-12-04 19:58 ` Yeoreum Yun
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=sashiko-outbox-250079@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=hannes@cmpxchg.org \
--cc=harrison@crosse.dev \
--cc=jack@suse.cz \
--cc=jannh@google.com \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=josef@toxicpanda.com \
--cc=liam@infradead.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mhocko@suse.com \
--cc=peterx@redhat.com \
--cc=pfalcato@suse.de \
--cc=rppt@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
--cc=yeoreum.yun@arm.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