All of lore.kernel.org
 help / color / mirror / Atom feed
* + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch
@ 2022-09-07 23:34 Andrew Morton
  2022-09-09 14:11 ` Peter Xu
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2022-09-07 23:34 UTC (permalink / raw)
  To: mm-commits, peterx, jhubbard, jgg, david, apopple, chenwandun, akpm


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@huawei.com>
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@huawei.com
Signed-off-by: Chen Wandun <chenwandun@huawei.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Peter Xu <peterx@redhat.com>
Cc: Alistair Popple <apopple@nvidia.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 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@huawei.com are

mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch
  2022-09-07 23:34 + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch Andrew Morton
@ 2022-09-09 14:11 ` Peter Xu
  2022-09-09 16:42   ` David Hildenbrand
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Xu @ 2022-09-09 14:11 UTC (permalink / raw)
  To: Andrew Morton; +Cc: mm-commits, jhubbard, jgg, david, apopple, chenwandun

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@huawei.com>
> 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@huawei.com
> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Jason Gunthorpe <jgg@nvidia.com>
> Cc: John Hubbard <jhubbard@nvidia.com>
> Cc: Peter Xu <peterx@redhat.com>
> Cc: Alistair Popple <apopple@nvidia.com>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> 
>  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@huawei.com are
> 
> mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch
> 

-- 
Peter Xu


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch
  2022-09-09 14:11 ` Peter Xu
@ 2022-09-09 16:42   ` David Hildenbrand
  2022-09-09 19:00     ` John Hubbard
  0 siblings, 1 reply; 4+ messages in thread
From: David Hildenbrand @ 2022-09-09 16:42 UTC (permalink / raw)
  To: Peter Xu, Andrew Morton; +Cc: mm-commits, jhubbard, jgg, apopple, chenwandun

On 09.09.22 16:11, Peter Xu wrote:
> 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@huawei.com>
>> 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@huawei.com
>> Signed-off-by: Chen Wandun <chenwandun@huawei.com>
>> Cc: David Hildenbrand <david@redhat.com>
>> Cc: Jason Gunthorpe <jgg@nvidia.com>
>> Cc: John Hubbard <jhubbard@nvidia.com>
>> Cc: Peter Xu <peterx@redhat.com>
>> Cc: Alistair Popple <apopple@nvidia.com>
>> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
>> ---
>>
>>   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.

Right. handle_mm_fault() returning 0 does not imply that the fault was 
fully resolved.

-- 
Thanks,

David / dhildenb


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch
  2022-09-09 16:42   ` David Hildenbrand
@ 2022-09-09 19:00     ` John Hubbard
  0 siblings, 0 replies; 4+ messages in thread
From: John Hubbard @ 2022-09-09 19:00 UTC (permalink / raw)
  To: David Hildenbrand, Peter Xu, Andrew Morton
  Cc: mm-commits, jgg, apopple, chenwandun

On 9/9/22 09:42, David Hildenbrand wrote:
...
>>> +				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.
>>

My mistake for overlooking that super-important point, in review!


thanks,

-- 
John Hubbard
NVIDIA


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-09-09 19:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-07 23:34 + mm-avoid-unnecessary-page-table-walk-for-__get_user_pages.patch added to mm-unstable branch Andrew Morton
2022-09-09 14:11 ` Peter Xu
2022-09-09 16:42   ` David Hildenbrand
2022-09-09 19:00     ` John Hubbard

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.