linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC
@ 2024-06-29 23:41 Barry Song
  2024-07-01  8:48 ` Ryan Roberts
  2024-07-01  8:51 ` David Hildenbrand
  0 siblings, 2 replies; 5+ messages in thread
From: Barry Song @ 2024-06-29 23:41 UTC (permalink / raw)
  To: akpm, linux-mm; +Cc: linux-kernel, Barry Song, David Hildenbrand, Ryan Roberts

From: Barry Song <v-songbaohua@oppo.com>

The optimization of list_empty(&folio->_deferred_list) aimed to prevent
increasing the PTL duration when a large folio is partially unmapped,
for example, from subpage 0 to subpage (nr - 2).

But Ryan's commit 5ed890ce5147 ("mm: vmscan: avoid split during
shrink_folio_list()") actually splits this kind of large folios. This
makes the "optimization" useless.

Signed-off-by: Barry Song <v-songbaohua@oppo.com>
Cc: David Hildenbrand <david@redhat.com>
Cc: Ryan Roberts <ryan.roberts@arm.com>
---
 -v1
 * I remember David and Ryan once suggested that this check could be dropped
   while the patch was being pulled into mm-unstable. However, for some reason,
   I forgot to request squashing this change.

 mm/vmscan.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/vmscan.c b/mm/vmscan.c
index 3d4c681c6d40..0761f91b407f 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1291,7 +1291,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
 			 * try_to_unmap acquire PTL from the first PTE,
 			 * eliminating the influence of temporary PTE values.
 			 */
-			if (folio_test_large(folio) && list_empty(&folio->_deferred_list))
+			if (folio_test_large(folio))
 				flags |= TTU_SYNC;
 
 			try_to_unmap(folio, flags);
-- 
2.34.1



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

* Re: [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC
  2024-06-29 23:41 [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC Barry Song
@ 2024-07-01  8:48 ` Ryan Roberts
  2024-07-01  9:35   ` Barry Song
  2024-07-01  8:51 ` David Hildenbrand
  1 sibling, 1 reply; 5+ messages in thread
From: Ryan Roberts @ 2024-07-01  8:48 UTC (permalink / raw)
  To: Barry Song, akpm, linux-mm; +Cc: linux-kernel, Barry Song, David Hildenbrand

On 30/06/2024 00:41, Barry Song wrote:
> From: Barry Song <v-songbaohua@oppo.com>
> 
> The optimization of list_empty(&folio->_deferred_list) aimed to prevent
> increasing the PTL duration when a large folio is partially unmapped,
> for example, from subpage 0 to subpage (nr - 2).
> 
> But Ryan's commit 5ed890ce5147 ("mm: vmscan: avoid split during
> shrink_folio_list()") actually splits this kind of large folios. This
> makes the "optimization" useless.
> 
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>

Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>

> ---
>  -v1
>  * I remember David and Ryan once suggested that this check could be dropped
>    while the patch was being pulled into mm-unstable. However, for some reason,
>    I forgot to request squashing this change.
> 
>  mm/vmscan.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 3d4c681c6d40..0761f91b407f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1291,7 +1291,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>  			 * try_to_unmap acquire PTL from the first PTE,
>  			 * eliminating the influence of temporary PTE values.
>  			 */
> -			if (folio_test_large(folio) && list_empty(&folio->_deferred_list))
> +			if (folio_test_large(folio))

As it stands, the list_empty() technically needs a data_race() annotation. I
think your original patch went into v6.10-rc1? If so, perhaps it makes sense to
try to get this into the next rc?

>  				flags |= TTU_SYNC;
>  
>  			try_to_unmap(folio, flags);



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

* Re: [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC
  2024-06-29 23:41 [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC Barry Song
  2024-07-01  8:48 ` Ryan Roberts
@ 2024-07-01  8:51 ` David Hildenbrand
  1 sibling, 0 replies; 5+ messages in thread
From: David Hildenbrand @ 2024-07-01  8:51 UTC (permalink / raw)
  To: Barry Song, akpm, linux-mm; +Cc: linux-kernel, Barry Song, Ryan Roberts

On 30.06.24 01:41, Barry Song wrote:
> From: Barry Song <v-songbaohua@oppo.com>
> 
> The optimization of list_empty(&folio->_deferred_list) aimed to prevent
> increasing the PTL duration when a large folio is partially unmapped,
> for example, from subpage 0 to subpage (nr - 2).
> 
> But Ryan's commit 5ed890ce5147 ("mm: vmscan: avoid split during
> shrink_folio_list()") actually splits this kind of large folios. This
> makes the "optimization" useless.
> 
> Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Ryan Roberts <ryan.roberts@arm.com>
> ---
>   -v1
>   * I remember David and Ryan once suggested that this check could be dropped
>     while the patch was being pulled into mm-unstable. However, for some reason,
>     I forgot to request squashing this change.
> 
>   mm/vmscan.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 3d4c681c6d40..0761f91b407f 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1291,7 +1291,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>   			 * try_to_unmap acquire PTL from the first PTE,
>   			 * eliminating the influence of temporary PTE values.
>   			 */
> -			if (folio_test_large(folio) && list_empty(&folio->_deferred_list))
> +			if (folio_test_large(folio))
>   				flags |= TTU_SYNC;
>   
>   			try_to_unmap(folio, flags);

Reviewed-by: David Hildenbrand <david@redhat.com>

-- 
Cheers,

David / dhildenb



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

* Re: [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC
  2024-07-01  8:48 ` Ryan Roberts
@ 2024-07-01  9:35   ` Barry Song
  2024-07-02  6:32     ` Andrew Morton
  0 siblings, 1 reply; 5+ messages in thread
From: Barry Song @ 2024-07-01  9:35 UTC (permalink / raw)
  To: Ryan Roberts; +Cc: akpm, linux-mm, linux-kernel, Barry Song, David Hildenbrand

On Mon, Jul 1, 2024 at 8:48 PM Ryan Roberts <ryan.roberts@arm.com> wrote:
>
> On 30/06/2024 00:41, Barry Song wrote:
> > From: Barry Song <v-songbaohua@oppo.com>
> >
> > The optimization of list_empty(&folio->_deferred_list) aimed to prevent
> > increasing the PTL duration when a large folio is partially unmapped,
> > for example, from subpage 0 to subpage (nr - 2).
> >
> > But Ryan's commit 5ed890ce5147 ("mm: vmscan: avoid split during
> > shrink_folio_list()") actually splits this kind of large folios. This
> > makes the "optimization" useless.
> >
> > Signed-off-by: Barry Song <v-songbaohua@oppo.com>
> > Cc: David Hildenbrand <david@redhat.com>
> > Cc: Ryan Roberts <ryan.roberts@arm.com>
>
> Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
>
> > ---
> >  -v1
> >  * I remember David and Ryan once suggested that this check could be dropped
> >    while the patch was being pulled into mm-unstable. However, for some reason,
> >    I forgot to request squashing this change.
> >
> >  mm/vmscan.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/mm/vmscan.c b/mm/vmscan.c
> > index 3d4c681c6d40..0761f91b407f 100644
> > --- a/mm/vmscan.c
> > +++ b/mm/vmscan.c
> > @@ -1291,7 +1291,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
> >                        * try_to_unmap acquire PTL from the first PTE,
> >                        * eliminating the influence of temporary PTE values.
> >                        */
> > -                     if (folio_test_large(folio) && list_empty(&folio->_deferred_list))
> > +                     if (folio_test_large(folio))
>
> As it stands, the list_empty() technically needs a data_race() annotation. I
> think your original patch went into v6.10-rc1? If so, perhaps it makes sense to
> try to get this into the next rc?

Either way is fine. Hi Andrew, if you include it for the next RC, could you
please add this tag?

Fixes: 73bc32875ee9 ("mm: hold PTL from the first PTE while reclaiming
a large folio")

And an additional changelog:

Additionally, the list_empty() technically requires a data_race() annotation.

>
> >                               flags |= TTU_SYNC;
> >
> >                       try_to_unmap(folio, flags);
>

Thanks
Barry


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

* Re: [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC
  2024-07-01  9:35   ` Barry Song
@ 2024-07-02  6:32     ` Andrew Morton
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Morton @ 2024-07-02  6:32 UTC (permalink / raw)
  To: Barry Song
  Cc: Ryan Roberts, linux-mm, linux-kernel, Barry Song, David Hildenbrand

On Mon, 1 Jul 2024 21:35:41 +1200 Barry Song <21cnbao@gmail.com> wrote:

> > > +++ b/mm/vmscan.c
> > > @@ -1291,7 +1291,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
> > >                        * try_to_unmap acquire PTL from the first PTE,
> > >                        * eliminating the influence of temporary PTE values.
> > >                        */
> > > -                     if (folio_test_large(folio) && list_empty(&folio->_deferred_list))
> > > +                     if (folio_test_large(folio))
> >
> > As it stands, the list_empty() technically needs a data_race() annotation. I
> > think your original patch went into v6.10-rc1? If so, perhaps it makes sense to
> > try to get this into the next rc?
> 
> Either way is fine. Hi Andrew, if you include it for the next RC, could you
> please add this tag?
> 
> Fixes: 73bc32875ee9 ("mm: hold PTL from the first PTE while reclaiming
> a large folio")

Nope!  That invites people to backport this change into kernels which
don't contain Ryan's 5ed890ce5147 ("mm: vmscan: avoid split during
shrink_folio_list()").

I'll simply queue this in the normal fashion.

> And an additional changelog:
> 
> Additionally, the list_empty() technically requires a data_race() annotation.

Done, thanks.


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

end of thread, other threads:[~2024-07-02  6:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-29 23:41 [PATCH] mm/vmscan: drop checking if _deferred_list is empty before using TTU_SYNC Barry Song
2024-07-01  8:48 ` Ryan Roberts
2024-07-01  9:35   ` Barry Song
2024-07-02  6:32     ` Andrew Morton
2024-07-01  8:51 ` David Hildenbrand

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox