The patch titled Subject: mm-add-apply_to_existing_pages-helper-fix has been removed from the -mm tree. Its filename was mm-add-apply_to_existing_pages-helper-fix.patch This patch was dropped because it was folded into mm-add-apply_to_existing_pages-helper.patch ------------------------------------------------------ From: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> Subject: mm-add-apply_to_existing_pages-helper-fix reduce code duplication Cc: Daniel Axtens <dja@xxxxxxxxxx> Cc: Alexander Potapenko <glider@xxxxxxxxxx> Cc: Andrey Ryabinin <aryabinin@xxxxxxxxxxxxx> Cc: Dmitry Vyukov <dvyukov@xxxxxxxxxx> Cc: Qian Cai <cai@xxxxxx> Cc: Uladzislau Rezki (Sony) <urezki@xxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory.c | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) --- a/mm/memory.c~mm-add-apply_to_existing_pages-helper-fix +++ a/mm/memory.c @@ -2141,12 +2141,9 @@ static int apply_to_p4d_range(struct mm_ return err; } -/* - * Scan a region of virtual memory, filling in page tables as necessary - * and calling a provided function on each leaf page table. - */ -int apply_to_page_range(struct mm_struct *mm, unsigned long addr, - unsigned long size, pte_fn_t fn, void *data) +static int __apply_to_page_range(struct mm_struct *mm, unsigned long addr, + unsigned long size, pte_fn_t fn, + void *data, bool create) { pgd_t *pgd; unsigned long next; @@ -2159,13 +2156,25 @@ int apply_to_page_range(struct mm_struct pgd = pgd_offset(mm, addr); do { next = pgd_addr_end(addr, end); - err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, true); + if (!create && pgd_none_or_clear_bad(pgd)) + continue; + err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, create); if (err) break; } while (pgd++, addr = next, addr != end); return err; } + +/* + * Scan a region of virtual memory, filling in page tables as necessary + * and calling a provided function on each leaf page table. + */ +int apply_to_page_range(struct mm_struct *mm, unsigned long addr, + unsigned long size, pte_fn_t fn, void *data) +{ + return __apply_to_page_range(mm, addr, size, fn, data, true); +} EXPORT_SYMBOL_GPL(apply_to_page_range); /* @@ -2178,25 +2187,7 @@ EXPORT_SYMBOL_GPL(apply_to_page_range); int apply_to_existing_pages(struct mm_struct *mm, unsigned long addr, unsigned long size, pte_fn_t fn, void *data) { - pgd_t *pgd; - unsigned long next; - unsigned long end = addr + size; - int err = 0; - - if (WARN_ON(addr >= end)) - return -EINVAL; - - pgd = pgd_offset(mm, addr); - do { - next = pgd_addr_end(addr, end); - if (pgd_none_or_clear_bad(pgd)) - continue; - err = apply_to_p4d_range(mm, pgd, addr, next, fn, data, false); - if (err) - break; - } while (pgd++, addr = next, addr != end); - - return err; + return __apply_to_page_range(mm, addr, size, fn, data, false); } EXPORT_SYMBOL_GPL(apply_to_existing_pages); _ Patches currently in -mm which might be from akpm@xxxxxxxxxxxxxxxxxxxx are mm-add-apply_to_existing_pages-helper.patch mm-add-apply_to_existing_pages-helper-fix-fix.patch mm-add-apply_to_existing_pages-helper-fix-fix-fix.patch kasan-use-apply_to_existing_pages-for-releasing-vmalloc-shadow-fix.patch lib-kconfigdebug-fix-some-messed-up-configurations-checkpatch-fixes.patch mm-gup-fix-memory-leak-in-__gup_benchmark_ioctl-fix.patch mm.patch mm-oom-avoid-printk-iteration-under-rcu-fix.patch linux-next-git-rejects.patch drivers-block-null_blk_mainc-fix-layout.patch drivers-block-null_blk_mainc-fix-uninitialized-var-warnings.patch drivers-tty-serial-sh-scic-suppress-warning.patch kernel-forkc-export-kernel_thread-to-modules.patch