diff mbox series

[RFC,1/8] mm: fix shmem swapout statistic

Message ID f467d0e9a021f4bd95588b9d888f1740fab3e3bc.1716285099.git.baolin.wang@linux.alibaba.com (mailing list archive)
State New
Headers show
Series support large folio swap-out and swap-in for shmem | expand

Commit Message

Baolin Wang May 21, 2024, 11:03 a.m. UTC
As we know, shmem not only supports the sharing of anonymous pages, but also
the RAM-based temporary filesystem. Therefore, shmem swapouts should not be
marked as anonymous swapout statistics. Fix it by adding folio_test_anon().

Fixes: d0f048ac39f6 ("mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters")
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
 mm/page_io.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Huang, Ying May 22, 2024, 7:16 a.m. UTC | #1
Baolin Wang <baolin.wang@linux.alibaba.com> writes:

> As we know, shmem not only supports the sharing of anonymous pages, but also
> the RAM-based temporary filesystem. Therefore, shmem swapouts should not be
> marked as anonymous swapout statistics. Fix it by adding folio_test_anon().
>
> Fixes: d0f048ac39f6 ("mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters")
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
>  mm/page_io.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/mm/page_io.c b/mm/page_io.c
> index 46c603dddf04..b181b81f39e3 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -217,7 +217,9 @@ static inline void count_swpout_vm_event(struct folio *folio)
>  		count_memcg_folio_events(folio, THP_SWPOUT, 1);
>  		count_vm_event(THP_SWPOUT);
>  	}
> -	count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
> +
> +	if (folio_test_anon(folio))
> +		count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);

Do we need to distinguish anonymous swapout and non-anonymous swapout?
IMHO, we don't.  Just like we have done for small folio and THP.

If so, how about fix this in another direction?  That is, remove "ANON"
from mTHP swapout statistics?

>  #endif
>  	count_vm_events(PSWPOUT, folio_nr_pages(folio));
>  }

--
Best Regards,
Huang, Ying
Baolin Wang May 22, 2024, 7:54 a.m. UTC | #2
On 2024/5/22 15:16, Huang, Ying wrote:
> Baolin Wang <baolin.wang@linux.alibaba.com> writes:
> 
>> As we know, shmem not only supports the sharing of anonymous pages, but also
>> the RAM-based temporary filesystem. Therefore, shmem swapouts should not be
>> marked as anonymous swapout statistics. Fix it by adding folio_test_anon().
>>
>> Fixes: d0f048ac39f6 ("mm: add per-order mTHP anon_swpout and anon_swpout_fallback counters")
>> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
>> ---
>>   mm/page_io.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/mm/page_io.c b/mm/page_io.c
>> index 46c603dddf04..b181b81f39e3 100644
>> --- a/mm/page_io.c
>> +++ b/mm/page_io.c
>> @@ -217,7 +217,9 @@ static inline void count_swpout_vm_event(struct folio *folio)
>>   		count_memcg_folio_events(folio, THP_SWPOUT, 1);
>>   		count_vm_event(THP_SWPOUT);
>>   	}
>> -	count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
>> +
>> +	if (folio_test_anon(folio))
>> +		count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
> 
> Do we need to distinguish anonymous swapout and non-anonymous swapout?
> IMHO, we don't.  Just like we have done for small folio and THP.

Yes, old counters did not add 'anon_' prefix.

> If so, how about fix this in another direction?  That is, remove "ANON"
> from mTHP swapout statistics?

This sounds good to me. And I will separate out an individual patch with 
your suggestion. Thanks.
diff mbox series

Patch

diff --git a/mm/page_io.c b/mm/page_io.c
index 46c603dddf04..b181b81f39e3 100644
--- a/mm/page_io.c
+++ b/mm/page_io.c
@@ -217,7 +217,9 @@  static inline void count_swpout_vm_event(struct folio *folio)
 		count_memcg_folio_events(folio, THP_SWPOUT, 1);
 		count_vm_event(THP_SWPOUT);
 	}
-	count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
+
+	if (folio_test_anon(folio))
+		count_mthp_stat(folio_order(folio), MTHP_STAT_ANON_SWPOUT);
 #endif
 	count_vm_events(PSWPOUT, folio_nr_pages(folio));
 }