* [merged mm-stable] mm-memory-simplify-error-handling-in-insert_pages.patch removed from -mm tree
@ 2026-10-07 0:50 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-07 0:50 UTC (permalink / raw)
To: mm-commits, vbabka, surenb, rppt, mhocko, ljs, liam, david,
thnkslprpt, akpm
The quilt patch titled
Subject: mm/memory: simplify error handling in insert_pages()
has been removed from the -mm tree. Its filename was
mm-memory-simplify-error-handling-in-insert_pages.patch
This patch was dropped because it was merged into the mm-stable branch
of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
------------------------------------------------------
From: Avi Weiss <thnkslprpt@gmail.com>
Subject: mm/memory: simplify error handling in insert_pages()
Date: Sat, 29 Aug 2026 20:11:12 +0300
Patch series "mm/memory: improve insert_pages() error handling", v3.
Improve insert_pages() error handling.
The first patch simplifies error handling by initializing the error status
to zero and assigning error codes at their respective failure sites.
The second patch returns -ENOMEM when walk_to_pmd() fails. A NULL return
from walk_to_pmd() indicates failure to allocate an upper page-table
level, so -ENOMEM is more appropriate than -EFAULT and is consistent with
the subsequent pte_alloc() failure.
This patch (of 2):
Initialize error return status to zero and then set it as needed at each
point of failure.
Assign -ENOMEM explicitly when pte_alloc() fails as the pte_alloc() macro
returns a boolean.
Link: https://lore.kernel.org/cover.1788022178.git.thnkslprpt@gmail.com
Link: https://lore.kernel.org/dd3a672c858b38c7525541b19a919e120c4e5a0e.1788022178.git.thnkslprpt@gmail.com
Signed-off-by: Avi Weiss <thnkslprpt@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Acked-by: David Hildenbrand (Arm) <david@kernel.org>
Reviewed-by: Lorenzo Stoakes (ARM) <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Mike Rapoport <rppt@kernel.org>
Cc: Suren Baghdasaryan <surenb@google.com>
Cc: Vlastimil Babka <vbabka@kernel.org>
---
mm/memory.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
--- a/mm/memory.c~mm-memory-simplify-error-handling-in-insert_pages
+++ a/mm/memory.c
@@ -2565,20 +2565,22 @@ static int insert_pages(struct vm_area_s
unsigned long curr_page_idx = 0;
unsigned long remaining_pages_total = *num;
unsigned long pages_to_write_in_pmd;
- int ret;
+ int err = 0;
more:
- ret = -EFAULT;
pmd = walk_to_pmd(mm, addr);
- if (!pmd)
+ if (!pmd) {
+ err = -EFAULT;
goto out;
+ }
pages_to_write_in_pmd = min_t(unsigned long,
remaining_pages_total, PTRS_PER_PTE - pte_index(addr));
/* Allocate the PTE if necessary; takes PMD lock once only. */
- ret = -ENOMEM;
- if (pte_alloc(mm, pmd))
+ if (pte_alloc(mm, pmd)) {
+ err = -ENOMEM;
goto out;
+ }
while (pages_to_write_in_pmd) {
int pte_idx = 0;
@@ -2586,15 +2588,14 @@ more:
start_pte = pte_offset_map_lock(mm, pmd, addr, &pte_lock);
if (!start_pte) {
- ret = -EFAULT;
+ err = -EFAULT;
goto out;
}
for (pte = start_pte; pte_idx < batch_size; ++pte, ++pte_idx) {
- int err = insert_page_in_batch_locked(vma, pte,
- addr, pages[curr_page_idx], prot);
+ err = insert_page_in_batch_locked(vma, pte, addr,
+ pages[curr_page_idx], prot);
if (unlikely(err)) {
pte_unmap_unlock(start_pte, pte_lock);
- ret = err;
remaining_pages_total -= pte_idx;
goto out;
}
@@ -2607,10 +2608,9 @@ more:
}
if (remaining_pages_total)
goto more;
- ret = 0;
out:
*num = remaining_pages_total;
- return ret;
+ return err;
}
/**
_
Patches currently in -mm which might be from thnkslprpt@gmail.com are
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-07 0:50 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 0:50 [merged mm-stable] mm-memory-simplify-error-handling-in-insert_pages.patch removed from -mm tree Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.