The patch titled Subject: mm: avoid unnecessary page table walk for __get_user_pages has been added to the -mm mm-unstable branch. Its filename is mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Chen Wandun <chenwandun@xxxxxxxxxx> Subject: mm: avoid unnecessary page table walk for __get_user_pages Date: Tue, 6 Sep 2022 10:44:01 +0800 There is no need to walk page tables and find pages if faultin_page)_ succeeds and __get_user_pages)_ doesn't care about populating the pages[] array. So directly go on to handle the next page. Link: https://lkml.kernel.org/r/20220906024401.133336-1-chenwandun@xxxxxxxxxx Signed-off-by: Chen Wandun <chenwandun@xxxxxxxxxx> Cc: David Hildenbrand <david@xxxxxxxxxx> Cc: Jason Gunthorpe <jgg@xxxxxxxxxx> Cc: John Hubbard <jhubbard@xxxxxxxxxx> Cc: Peter Xu <peterx@xxxxxxxxxx> Cc: Alistair Popple <apopple@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/gup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) --- a/mm/gup.c~mm-avoid-unnecessary-page-table-walk-for-__get_user_pages +++ a/mm/gup.c @@ -1175,7 +1175,10 @@ retry: PTR_ERR(page) == -EMLINK, locked); switch (ret) { case 0: - goto retry; + if (pages) + goto retry; + else + goto next_page; case -EBUSY: case -EAGAIN: ret = 0; _ Patches currently in -mm which might be from chenwandun@xxxxxxxxxx are mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch