* [PATCH 0/3] mm: gup: handle fault retries in __mm_populate()
@ 2026-12-03 15:17 Yeoreum Yun
2026-12-03 15:17 ` [PATCH 1/3] " Yeoreum Yun
` (3 more replies)
0 siblings, 4 replies; 9+ messages in thread
From: Yeoreum Yun @ 2026-12-03 15:17 UTC (permalink / raw)
To: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jann Horn, Pedro Falcato
Cc: David Hildenbrand, Andrew Morton, Harrison Crosse, Yeoreum Yun
When populating a file mapping whose reads repeatedly fail,
__mm_populate() can retry the same page indefinitely [1].
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.
This patch series addresses this problem including small cleanup and
based on mm-core/for-next
To: Jason Gunthorpe <jgg@ziepe.ca>
To: John Hubbard <jhubbard@nvidia.com>
To: Peter Xu <peterx@redhat.com>
To: linux-mm@kvack.org
To: Jan Kara <jack@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
To: Johannes Weiner <hannes@cmpxchg.org>
To: Lorenzo Stoakes <ljs@kernel.org>
To: Liam R. Howlett <liam@infradead.org>
To: Vlastimil Babka <vbabka@kernel.org>
To: Mike Rapoport <rppt@kernel.org>
To: Suren Baghdasaryan <surenb@google.com>
To: Michal Hocko <mhocko@suse.com>
To: Jann Horn <jannh@google.com>
To: Pedro Falcato <pfalcato@suse.de>
Cc: David Hildenbrand <david@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Harrison Crosse <harrison@crosse.dev>
Link: [1] https://lore.kernel.org/all/20261118-mmpop-populate-v1-1-9c561d178d11@crosse.dev/
---
Yeoreum Yun (3):
mm: gup: handle fault retries in __mm_populate()
mm: gup: remove unused argument in populate_vma_page_range()
mm: gup: make mmap_lock acquisition in __mm_populate() killable
mm/gup.c | 30 ++++++++++++++++++++++++------
mm/internal.h | 2 +-
mm/mmap.c | 4 ++--
mm/mprotect.c | 2 +-
4 files changed, 28 insertions(+), 10 deletions(-)
---
base-commit: c03465593e556e594b4efb1f6cb26565f11dc8b8
change-id: 20261201-infinite_mm_populate-6d659390695d
Best regards,
--
Sincerely,
Yeoreum Yun
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH 1/3] mm: gup: handle fault retries in __mm_populate()
2026-12-03 15:17 [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Yeoreum Yun
@ 2026-12-03 15:17 ` Yeoreum Yun
2026-12-04 3:23 ` Liam R. Howlett
2026-12-04 5:29 ` kernel test robot
2026-12-03 15:17 ` [PATCH 2/3] mm: gup: remove unused argument in populate_vma_page_range() Yeoreum Yun
` (2 subsequent siblings)
3 siblings, 2 replies; 9+ messages in thread
From: Yeoreum Yun @ 2026-12-03 15:17 UTC (permalink / raw)
To: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jann Horn, Pedro Falcato
Cc: David Hildenbrand, Andrew Morton, Harrison Crosse, Yeoreum Yun
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>
---
mm/gup.c | 27 ++++++++++++++++++++++-----
1 file changed, 22 insertions(+), 5 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index ec0bc9920216..d2ff0b667e37 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)
{
struct mm_struct *mm = vma->vm_mm;
unsigned long nr_pages = (end - start) / PAGE_SIZE;
@@ -1949,8 +1949,10 @@ long populate_vma_page_range(struct vm_area_struct *vma,
else
gup_flags |= FOLL_FORCE;
- if (locked)
+ if (locked) {
gup_flags |= FOLL_UNLOCKABLE;
+ gup_flags |= (retry) ? FOLL_TRIED : 0;
+ }
/*
* We made sure addr is within a VMA, so the following will
@@ -1962,6 +1964,13 @@ long populate_vma_page_range(struct vm_area_struct *vma,
return ret;
}
+
+long populate_vma_page_range(struct vm_area_struct *vma,
+ unsigned long start, unsigned long end, int *locked)
+{
+ return __populate_vma_page_range(vma, start, end, locked, false);
+}
+
/*
* faultin_page_range() - populate (prefault) page tables inside the
* given range readable/writable
@@ -2028,10 +2037,12 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
struct vm_area_struct *vma = NULL;
int locked = 0;
long ret = 0;
+ bool tried = false;
end = start + len;
for (nstart = start; nstart < end; nstart = nend) {
+ unsigned long populate_end;
/*
* We want to fault in pages for [nstart; end) address range.
* Find first corresponding VMA.
@@ -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;
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/3] mm: gup: remove unused argument in populate_vma_page_range()
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-03 15:17 ` Yeoreum Yun
2026-12-04 3:28 ` Liam R. Howlett
2026-12-03 15:17 ` [PATCH 3/3] mm: gup: make mmap_lock acquisition in __mm_populate() killable Yeoreum Yun
2026-12-04 3:23 ` [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Liam R. Howlett
3 siblings, 1 reply; 9+ messages in thread
From: Yeoreum Yun @ 2026-12-03 15:17 UTC (permalink / raw)
To: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jann Horn, Pedro Falcato
Cc: David Hildenbrand, Andrew Morton, Harrison Crosse, Yeoreum Yun
Current users of populate_vma_page_range() set locked argument as NULL
always. Therefore, remove locked argument from it.
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
mm/gup.c | 4 ++--
mm/internal.h | 2 +-
mm/mmap.c | 4 ++--
mm/mprotect.c | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/mm/gup.c b/mm/gup.c
index d2ff0b667e37..4c0d00c37c21 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1966,9 +1966,9 @@ static long __populate_vma_page_range(struct vm_area_struct *vma,
long populate_vma_page_range(struct vm_area_struct *vma,
- unsigned long start, unsigned long end, int *locked)
+ unsigned long start, unsigned long end)
{
- return __populate_vma_page_range(vma, start, end, locked, false);
+ return __populate_vma_page_range(vma, start, end, NULL, false);
}
/*
diff --git a/mm/internal.h b/mm/internal.h
index 2132dd593b44..6d1dccd03284 100644
--- a/mm/internal.h
+++ b/mm/internal.h
@@ -945,7 +945,7 @@ struct anon_vma *folio_anon_vma(const struct folio *folio);
#ifdef CONFIG_MMU
void unmap_mapping_folio(struct folio *folio);
extern long populate_vma_page_range(struct vm_area_struct *vma,
- unsigned long start, unsigned long end, int *locked);
+ unsigned long start, unsigned long end);
extern long faultin_page_range(struct mm_struct *mm, unsigned long start,
unsigned long end, bool write, int *locked);
bool mlock_future_ok(const struct mm_struct *mm, bool is_vma_locked,
diff --git a/mm/mmap.c b/mm/mmap.c
index 7618e72766a5..4b104217a153 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -986,7 +986,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
if (expand_stack_locked(prev, addr))
return NULL;
if (vma_test(prev, VMA_LOCKED_BIT))
- populate_vma_page_range(prev, addr, prev->vm_end, NULL);
+ populate_vma_page_range(prev, addr, prev->vm_end);
return prev;
}
#else
@@ -1010,7 +1010,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
if (expand_stack_locked(vma, addr))
return NULL;
if (vma_test(vma, VMA_LOCKED_BIT))
- populate_vma_page_range(vma, addr, start, NULL);
+ populate_vma_page_range(vma, addr, start);
return vma;
}
#endif
diff --git a/mm/mprotect.c b/mm/mprotect.c
index e18d4e12fc34..209efa869174 100644
--- a/mm/mprotect.c
+++ b/mm/mprotect.c
@@ -851,7 +851,7 @@ mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
if (vma_flags_test(&new_vma_flags, VMA_WRITE_BIT) &&
vma_flags_test(&old_vma_flags, VMA_LOCKED_BIT) &&
!vma_flags_test_any(&old_vma_flags, VMA_WRITE_BIT, VMA_SHARED_BIT))
- populate_vma_page_range(vma, start, end, NULL);
+ populate_vma_page_range(vma, start, end);
vm_stat_account(mm, vma_flags_to_legacy(old_vma_flags), -nrpages);
newflags = vma_flags_to_legacy(new_vma_flags);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/3] mm: gup: make mmap_lock acquisition in __mm_populate() killable
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-03 15:17 ` [PATCH 2/3] mm: gup: remove unused argument in populate_vma_page_range() Yeoreum Yun
@ 2026-12-03 15:17 ` Yeoreum Yun
2026-12-04 3:35 ` Liam R. Howlett
2026-12-04 3:23 ` [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Liam R. Howlett
3 siblings, 1 reply; 9+ messages in thread
From: Yeoreum Yun @ 2026-12-03 15:17 UTC (permalink / raw)
To: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Liam R. Howlett,
Vlastimil Babka, Mike Rapoport, Suren Baghdasaryan, Michal Hocko,
Jann Horn, Pedro Falcato
Cc: David Hildenbrand, Andrew Morton, Harrison Crosse, Yeoreum Yun
__mm_populate() uses mmap_read_lock() to acquire mmap_lock.
If the lock is contended, a task waiting here cannot abort
the wait on a fatal signal.
Use mmap_read_lock_killable() and exit the populate loop if lock
acquisition is interrupted.
Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
---
mm/gup.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mm/gup.c b/mm/gup.c
index 4c0d00c37c21..65ce0c5a8e02 100644
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -2049,7 +2049,8 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
*/
if (!locked) {
locked = 1;
- mmap_read_lock(mm);
+ if (mmap_read_lock_killable(mm))
+ return -EINTR;
vma = find_vma_intersection(mm, nstart, end);
} else if (nstart >= vma->vm_end)
vma = find_vma_intersection(mm, vma->vm_end, end);
--
2.43.0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] mm: gup: handle fault retries in __mm_populate()
2026-12-03 15:17 ` [PATCH 1/3] " Yeoreum Yun
@ 2026-12-04 3:23 ` Liam R. Howlett
2026-12-04 5:29 ` kernel test robot
1 sibling, 0 replies; 9+ messages in thread
From: Liam R. Howlett @ 2026-12-04 3:23 UTC (permalink / raw)
To: Yeoreum Yun
Cc: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Jann Horn,
Pedro Falcato, David Hildenbrand, Andrew Morton, Harrison Crosse
On 26/12/03 03:17PM, Yeoreum Yun wrote:
> 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")
Cc: Stable ?
> Co-developed-by: Harrison Crosse <harrison@crosse.dev>
You are missing Harrison's signed-off-by here.
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> ---
> mm/gup.c | 27 ++++++++++++++++++++++-----
> 1 file changed, 22 insertions(+), 5 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index ec0bc9920216..d2ff0b667e37 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
Please add @retry: to the documentation, it'll create a warning for the
docs people otherwise.
> @@ -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)
> {
> struct mm_struct *mm = vma->vm_mm;
> unsigned long nr_pages = (end - start) / PAGE_SIZE;
> @@ -1949,8 +1949,10 @@ long populate_vma_page_range(struct vm_area_struct *vma,
> else
> gup_flags |= FOLL_FORCE;
>
> - if (locked)
> + if (locked) {
> gup_flags |= FOLL_UNLOCKABLE;
> + gup_flags |= (retry) ? FOLL_TRIED : 0;
> + }
An if statement is longer, but worth it here, imo.
>
> /*
> * We made sure addr is within a VMA, so the following will
> @@ -1962,6 +1964,13 @@ long populate_vma_page_range(struct vm_area_struct *vma,
> return ret;
> }
>
> +
double blank line.
> +long populate_vma_page_range(struct vm_area_struct *vma,
> + unsigned long start, unsigned long end, int *locked)
> +{
> + return __populate_vma_page_range(vma, start, end, locked, false);
> +}
> +
> /*
> * faultin_page_range() - populate (prefault) page tables inside the
> * given range readable/writable
> @@ -2028,10 +2037,12 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
> struct vm_area_struct *vma = NULL;
> int locked = 0;
> long ret = 0;
> + bool tried = false;
>
> end = start + len;
>
> for (nstart = start; nstart < end; nstart = nend) {
> + unsigned long populate_end;
> /*
> * We want to fault in pages for [nstart; end) address range.
> * Find first corresponding VMA.
> @@ -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 the lock is dropped and another thread unmaps or moves the page, the
retry will look up the vma at or after the start address and will hit
the wrong one.
The initial patch saved the retry_addr to avoid this.
> if (ret < 0) {
> if (ignore_errors) {
> ret = 0;
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 0/3] mm: gup: handle fault retries in __mm_populate()
2026-12-03 15:17 [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Yeoreum Yun
` (2 preceding siblings ...)
2026-12-03 15:17 ` [PATCH 3/3] mm: gup: make mmap_lock acquisition in __mm_populate() killable Yeoreum Yun
@ 2026-12-04 3:23 ` Liam R. Howlett
3 siblings, 0 replies; 9+ messages in thread
From: Liam R. Howlett @ 2026-12-04 3:23 UTC (permalink / raw)
To: Yeoreum Yun
Cc: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Jann Horn,
Pedro Falcato, David Hildenbrand, Andrew Morton, Harrison Crosse
On 26/12/03 03:17PM, Yeoreum Yun wrote:
> When populating a file mapping whose reads repeatedly fail,
> __mm_populate() can retry the same page indefinitely [1].
>
> 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.
>
> This patch series addresses this problem including small cleanup and
> based on mm-core/for-next
>
> To: Jason Gunthorpe <jgg@ziepe.ca>
> To: John Hubbard <jhubbard@nvidia.com>
> To: Peter Xu <peterx@redhat.com>
> To: linux-mm@kvack.org
> To: Jan Kara <jack@suse.cz>
> To: Josef Bacik <josef@toxicpanda.com>
> To: Johannes Weiner <hannes@cmpxchg.org>
> To: Lorenzo Stoakes <ljs@kernel.org>
> To: Liam R. Howlett <liam@infradead.org>
> To: Vlastimil Babka <vbabka@kernel.org>
> To: Mike Rapoport <rppt@kernel.org>
> To: Suren Baghdasaryan <surenb@google.com>
> To: Michal Hocko <mhocko@suse.com>
> To: Jann Horn <jannh@google.com>
> To: Pedro Falcato <pfalcato@suse.de>
> Cc: David Hildenbrand <david@kernel.org>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Harrison Crosse <harrison@crosse.dev>
>
> Link: [1] https://lore.kernel.org/all/20261118-mmpop-populate-v1-1-9c561d178d11@crosse.dev/
> ---
> Yeoreum Yun (3):
> mm: gup: handle fault retries in __mm_populate()
> mm: gup: remove unused argument in populate_vma_page_range()
> mm: gup: make mmap_lock acquisition in __mm_populate() killable
What about the test from the previous patches?
>
> mm/gup.c | 30 ++++++++++++++++++++++++------
> mm/internal.h | 2 +-
> mm/mmap.c | 4 ++--
> mm/mprotect.c | 2 +-
> 4 files changed, 28 insertions(+), 10 deletions(-)
> ---
> base-commit: c03465593e556e594b4efb1f6cb26565f11dc8b8
> change-id: 20261201-infinite_mm_populate-6d659390695d
>
> Best regards,
> --
> Sincerely,
> Yeoreum Yun
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 2/3] mm: gup: remove unused argument in populate_vma_page_range()
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
0 siblings, 0 replies; 9+ messages in thread
From: Liam R. Howlett @ 2026-12-04 3:28 UTC (permalink / raw)
To: Yeoreum Yun
Cc: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Jann Horn,
Pedro Falcato, David Hildenbrand, Andrew Morton, Harrison Crosse
On 26/12/03 03:17PM, Yeoreum Yun wrote:
> Current users of populate_vma_page_range() set locked argument as NULL
> always. Therefore, remove locked argument from it.
>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
Nit, the argument is used, it's just always passed through as null.
This also sounds like you found an existing issue, but you've removed
the last caller that used to pass a non-NULL argument here.
The code looks good, though.
> ---
> mm/gup.c | 4 ++--
> mm/internal.h | 2 +-
> mm/mmap.c | 4 ++--
> mm/mprotect.c | 2 +-
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index d2ff0b667e37..4c0d00c37c21 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -1966,9 +1966,9 @@ static long __populate_vma_page_range(struct vm_area_struct *vma,
>
>
> long populate_vma_page_range(struct vm_area_struct *vma,
> - unsigned long start, unsigned long end, int *locked)
> + unsigned long start, unsigned long end)
> {
> - return __populate_vma_page_range(vma, start, end, locked, false);
> + return __populate_vma_page_range(vma, start, end, NULL, false);
> }
>
> /*
> diff --git a/mm/internal.h b/mm/internal.h
> index 2132dd593b44..6d1dccd03284 100644
> --- a/mm/internal.h
> +++ b/mm/internal.h
> @@ -945,7 +945,7 @@ struct anon_vma *folio_anon_vma(const struct folio *folio);
> #ifdef CONFIG_MMU
> void unmap_mapping_folio(struct folio *folio);
> extern long populate_vma_page_range(struct vm_area_struct *vma,
> - unsigned long start, unsigned long end, int *locked);
> + unsigned long start, unsigned long end);
> extern long faultin_page_range(struct mm_struct *mm, unsigned long start,
> unsigned long end, bool write, int *locked);
> bool mlock_future_ok(const struct mm_struct *mm, bool is_vma_locked,
> diff --git a/mm/mmap.c b/mm/mmap.c
> index 7618e72766a5..4b104217a153 100644
> --- a/mm/mmap.c
> +++ b/mm/mmap.c
> @@ -986,7 +986,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
> if (expand_stack_locked(prev, addr))
> return NULL;
> if (vma_test(prev, VMA_LOCKED_BIT))
> - populate_vma_page_range(prev, addr, prev->vm_end, NULL);
> + populate_vma_page_range(prev, addr, prev->vm_end);
> return prev;
> }
> #else
> @@ -1010,7 +1010,7 @@ struct vm_area_struct *find_extend_vma_locked(struct mm_struct *mm, unsigned lon
> if (expand_stack_locked(vma, addr))
> return NULL;
> if (vma_test(vma, VMA_LOCKED_BIT))
> - populate_vma_page_range(vma, addr, start, NULL);
> + populate_vma_page_range(vma, addr, start);
> return vma;
> }
> #endif
> diff --git a/mm/mprotect.c b/mm/mprotect.c
> index e18d4e12fc34..209efa869174 100644
> --- a/mm/mprotect.c
> +++ b/mm/mprotect.c
> @@ -851,7 +851,7 @@ mprotect_fixup(struct vma_iterator *vmi, struct mmu_gather *tlb,
> if (vma_flags_test(&new_vma_flags, VMA_WRITE_BIT) &&
> vma_flags_test(&old_vma_flags, VMA_LOCKED_BIT) &&
> !vma_flags_test_any(&old_vma_flags, VMA_WRITE_BIT, VMA_SHARED_BIT))
> - populate_vma_page_range(vma, start, end, NULL);
> + populate_vma_page_range(vma, start, end);
>
> vm_stat_account(mm, vma_flags_to_legacy(old_vma_flags), -nrpages);
> newflags = vma_flags_to_legacy(new_vma_flags);
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 3/3] mm: gup: make mmap_lock acquisition in __mm_populate() killable
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
0 siblings, 0 replies; 9+ messages in thread
From: Liam R. Howlett @ 2026-12-04 3:35 UTC (permalink / raw)
To: Yeoreum Yun
Cc: Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm, Jan Kara,
Josef Bacik, Johannes Weiner, Lorenzo Stoakes, Vlastimil Babka,
Mike Rapoport, Suren Baghdasaryan, Michal Hocko, Jann Horn,
Pedro Falcato, David Hildenbrand, Andrew Morton, Harrison Crosse
On 26/12/03 03:17PM, Yeoreum Yun wrote:
> __mm_populate() uses mmap_read_lock() to acquire mmap_lock.
> If the lock is contended, a task waiting here cannot abort
> the wait on a fatal signal.
>
> Use mmap_read_lock_killable() and exit the populate loop if lock
> acquisition is interrupted.
You are restating the code here.
>
> Signed-off-by: Yeoreum Yun <yeoreum.yun@arm.com>
> ---
> mm/gup.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/mm/gup.c b/mm/gup.c
> index 4c0d00c37c21..65ce0c5a8e02 100644
> --- a/mm/gup.c
> +++ b/mm/gup.c
> @@ -2049,7 +2049,8 @@ int __mm_populate(unsigned long start, unsigned long len, int ignore_errors)
> */
> if (!locked) {
> locked = 1;
Please move the locked = 1 below the return on the failure of trying to
lock. It's fine today, but may not always be.
> - mmap_read_lock(mm);
> + if (mmap_read_lock_killable(mm))
> + return -EINTR;
> vma = find_vma_intersection(mm, nstart, end);
> } else if (nstart >= vma->vm_end)
> vma = find_vma_intersection(mm, vma->vm_end, end);
>
> --
> 2.43.0
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH 1/3] mm: gup: handle fault retries in __mm_populate()
2026-12-03 15:17 ` [PATCH 1/3] " Yeoreum Yun
2026-12-04 3:23 ` Liam R. Howlett
@ 2026-12-04 5:29 ` kernel test robot
1 sibling, 0 replies; 9+ messages in thread
From: kernel test robot @ 2026-12-04 5:29 UTC (permalink / raw)
To: Yeoreum Yun, Jason Gunthorpe, John Hubbard, Peter Xu, linux-mm,
Jan Kara, Josef Bacik, Johannes Weiner, Lorenzo Stoakes,
Liam R. Howlett, Vlastimil Babka, Mike Rapoport,
Suren Baghdasaryan, Michal Hocko, Jann Horn, Pedro Falcato
Cc: oe-kbuild-all, David Hildenbrand, Andrew Morton,
Linux Memory Management List, Harrison Crosse, Yeoreum Yun
Hi Yeoreum,
kernel test robot noticed the following build warnings:
[auto build test WARNING on c03465593e556e594b4efb1f6cb26565f11dc8b8]
url: https://github.com/intel-lab-lkp/linux/commits/Yeoreum-Yun/mm-gup-handle-fault-retries-in-__mm_populate/20261203-151717
base: c03465593e556e594b4efb1f6cb26565f11dc8b8
patch link: https://lore.kernel.org/r/20261203-infinite_mm_populate-v1-1-da5f1bccb3a2%40arm.com
patch subject: [PATCH 1/3] mm: gup: handle fault retries in __mm_populate()
config: x86_64-rhel-9.4 (https://download.01.org/0day-ci/archive/20261204/20261204131830.EGGhjNXO-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20261204/20261204131830.EGGhjNXO-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/20261204131830.EGGhjNXO-lkp@intel.com/
All warnings (new ones prefixed by >>):
>> Warning: mm/gup.c:1909 function parameter 'retry' not described in '__populate_vma_page_range'
>> Warning: mm/gup.c:1909 function parameter 'retry' not described in '__populate_vma_page_range'
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2026-12-04 5:30 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 5:29 ` kernel test robot
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-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 3:23 ` [PATCH 0/3] mm: gup: handle fault retries in __mm_populate() Liam R. Howlett
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox