Re: + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Sep 07, 2022 at 04:34:11PM -0700, Andrew Morton wrote:
> 
> 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;

Will this mess up the refcounts already?  afaict follow_page_mask() is the
only place to grab the pages, and GUP should need to take refcounts on
pages even without pages** being passed in.

Meanwhile I'd think there will be cases that require multiple entrances of
continuous follow_page_mask() + faultin_page() sequences, that even the
previous round of faultin_page() returned success but follow_page_mask()
may still want one more round of faulting for some reason to finally grab
the correct page.

> _
> 
> Patches currently in -mm which might be from chenwandun@xxxxxxxxxx are
> 
> mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch
> 

-- 
Peter Xu




[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux