* [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
@ 2024-12-05 3:53 Baolin Wang
2024-12-05 5:00 ` Barry Song
2024-12-05 5:39 ` Huang, Ying
0 siblings, 2 replies; 6+ messages in thread
From: Baolin Wang @ 2024-12-05 3:53 UTC (permalink / raw)
To: akpm; +Cc: 21cnbao, david, ying.huang, ziy, baolin.wang, linux-mm, linux-kernel
Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
a new anonymous counter per THP size, however, when folio_mapping() is not NULL
during folio migration, it means this is not an anonymous folio, so remove the
redundant anonymous statistics in this case.
Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
---
mm/migrate.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/mm/migrate.c b/mm/migrate.c
index e9e00d1d1d19..d7fdfdd23fd0 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -523,8 +523,6 @@ static int __folio_migrate_mapping(struct address_space *mapping,
*/
newfolio->index = folio->index;
newfolio->mapping = folio->mapping;
- if (folio_test_anon(folio) && folio_test_large(folio))
- mod_mthp_stat(folio_order(folio), MTHP_STAT_NR_ANON, 1);
folio_ref_add(newfolio, nr); /* add cache reference */
if (folio_test_swapbacked(folio)) {
__folio_set_swapbacked(newfolio);
--
2.39.3
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
2024-12-05 3:53 [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration Baolin Wang
@ 2024-12-05 5:00 ` Barry Song
2024-12-05 6:06 ` Baolin Wang
2024-12-05 5:39 ` Huang, Ying
1 sibling, 1 reply; 6+ messages in thread
From: Barry Song @ 2024-12-05 5:00 UTC (permalink / raw)
To: Baolin Wang; +Cc: akpm, david, ying.huang, ziy, linux-mm, linux-kernel
On Thu, Dec 5, 2024 at 4:54 PM Baolin Wang
<baolin.wang@linux.alibaba.com> wrote:
>
> Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
> a new anonymous counter per THP size, however, when folio_mapping() is not NULL
> during folio migration, it means this is not an anonymous folio, so remove the
> redundant anonymous statistics in this case.
why? Are you sure anon folios won't call __folio_migrate_mapping()?
folio->mapping is PAGE_MAPPING_ANON for anon folios.
static __always_inline bool folio_test_anon(const struct folio *folio)
{
return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0;
}
>
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> mm/migrate.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e9e00d1d1d19..d7fdfdd23fd0 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -523,8 +523,6 @@ static int __folio_migrate_mapping(struct address_space *mapping,
> */
> newfolio->index = folio->index;
> newfolio->mapping = folio->mapping;
> - if (folio_test_anon(folio) && folio_test_large(folio))
> - mod_mthp_stat(folio_order(folio), MTHP_STAT_NR_ANON, 1);
> folio_ref_add(newfolio, nr); /* add cache reference */
> if (folio_test_swapbacked(folio)) {
> __folio_set_swapbacked(newfolio);
> --
> 2.39.3
>
Thanks
Barry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
2024-12-05 3:53 [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration Baolin Wang
2024-12-05 5:00 ` Barry Song
@ 2024-12-05 5:39 ` Huang, Ying
1 sibling, 0 replies; 6+ messages in thread
From: Huang, Ying @ 2024-12-05 5:39 UTC (permalink / raw)
To: Baolin Wang; +Cc: akpm, 21cnbao, david, ziy, linux-mm, linux-kernel
Baolin Wang <baolin.wang@linux.alibaba.com> writes:
> Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
> a new anonymous counter per THP size, however, when folio_mapping() is not NULL
> during folio migration, it means this is not an anonymous folio, so remove the
> redundant anonymous statistics in this case.
They may be anonymous folios in swap cache?
> Signed-off-by: Baolin Wang <baolin.wang@linux.alibaba.com>
> ---
> mm/migrate.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/mm/migrate.c b/mm/migrate.c
> index e9e00d1d1d19..d7fdfdd23fd0 100644
> --- a/mm/migrate.c
> +++ b/mm/migrate.c
> @@ -523,8 +523,6 @@ static int __folio_migrate_mapping(struct address_space *mapping,
> */
> newfolio->index = folio->index;
> newfolio->mapping = folio->mapping;
> - if (folio_test_anon(folio) && folio_test_large(folio))
> - mod_mthp_stat(folio_order(folio), MTHP_STAT_NR_ANON, 1);
> folio_ref_add(newfolio, nr); /* add cache reference */
> if (folio_test_swapbacked(folio)) {
> __folio_set_swapbacked(newfolio);
---
Best Regards,
Huang, Ying
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
2024-12-05 5:00 ` Barry Song
@ 2024-12-05 6:06 ` Baolin Wang
2024-12-05 6:33 ` Barry Song
0 siblings, 1 reply; 6+ messages in thread
From: Baolin Wang @ 2024-12-05 6:06 UTC (permalink / raw)
To: Barry Song; +Cc: akpm, david, ying.huang, ziy, linux-mm, linux-kernel
On 2024/12/5 13:00, Barry Song wrote:
> On Thu, Dec 5, 2024 at 4:54 PM Baolin Wang
> <baolin.wang@linux.alibaba.com> wrote:
>>
>> Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
>> a new anonymous counter per THP size, however, when folio_mapping() is not NULL
>> during folio migration, it means this is not an anonymous folio, so remove the
>> redundant anonymous statistics in this case.
>
> why? Are you sure anon folios won't call __folio_migrate_mapping()?
> folio->mapping is PAGE_MAPPING_ANON for anon folios.
>
> static __always_inline bool folio_test_anon(const struct folio *folio)
> {
> return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0;
> }
Ah, sorry for noise. This just caught my eyes when reading the code, and
I did not think about it deeply before sending a quick patch. Thanks to
Barry and Ying for the reminder.
Andrew, please drop this quick patch. Sorry for the trouble.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
2024-12-05 6:06 ` Baolin Wang
@ 2024-12-05 6:33 ` Barry Song
2024-12-05 6:50 ` Baolin Wang
0 siblings, 1 reply; 6+ messages in thread
From: Barry Song @ 2024-12-05 6:33 UTC (permalink / raw)
To: Baolin Wang; +Cc: akpm, david, ying.huang, ziy, linux-mm, linux-kernel
On Thu, Dec 5, 2024 at 7:06 PM Baolin Wang
<baolin.wang@linux.alibaba.com> wrote:
>
>
>
> On 2024/12/5 13:00, Barry Song wrote:
> > On Thu, Dec 5, 2024 at 4:54 PM Baolin Wang
> > <baolin.wang@linux.alibaba.com> wrote:
> >>
> >> Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
> >> a new anonymous counter per THP size, however, when folio_mapping() is not NULL
> >> during folio migration, it means this is not an anonymous folio, so remove the
> >> redundant anonymous statistics in this case.
> >
> > why? Are you sure anon folios won't call __folio_migrate_mapping()?
> > folio->mapping is PAGE_MAPPING_ANON for anon folios.
> >
> > static __always_inline bool folio_test_anon(const struct folio *folio)
> > {
> > return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0;
> > }
>
> Ah, sorry for noise. This just caught my eyes when reading the code, and
> I did not think about it deeply before sending a quick patch. Thanks to
> Barry and Ying for the reminder.
No worries. I recall encountering a negative count during the development of
the original patch and eventually realizing it was due to forgetting
to increment
the migrated anon folios. Your patch seems to reintroduce the bug I encountered
back then :-)
>
> Andrew, please drop this quick patch. Sorry for the trouble.
>
Thanks
Barry
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration
2024-12-05 6:33 ` Barry Song
@ 2024-12-05 6:50 ` Baolin Wang
0 siblings, 0 replies; 6+ messages in thread
From: Baolin Wang @ 2024-12-05 6:50 UTC (permalink / raw)
To: Barry Song; +Cc: akpm, david, ying.huang, ziy, linux-mm, linux-kernel
On 2024/12/5 14:33, Barry Song wrote:
> On Thu, Dec 5, 2024 at 7:06 PM Baolin Wang
> <baolin.wang@linux.alibaba.com> wrote:
>>
>>
>>
>> On 2024/12/5 13:00, Barry Song wrote:
>>> On Thu, Dec 5, 2024 at 4:54 PM Baolin Wang
>>> <baolin.wang@linux.alibaba.com> wrote:
>>>>
>>>> Commit 5d65c8d758f2 ("mm: count the number of anonymous THPs per size") adds
>>>> a new anonymous counter per THP size, however, when folio_mapping() is not NULL
>>>> during folio migration, it means this is not an anonymous folio, so remove the
>>>> redundant anonymous statistics in this case.
>>>
>>> why? Are you sure anon folios won't call __folio_migrate_mapping()?
>>> folio->mapping is PAGE_MAPPING_ANON for anon folios.
>>>
>>> static __always_inline bool folio_test_anon(const struct folio *folio)
>>> {
>>> return ((unsigned long)folio->mapping & PAGE_MAPPING_ANON) != 0;
>>> }
>>
>> Ah, sorry for noise. This just caught my eyes when reading the code, and
>> I did not think about it deeply before sending a quick patch. Thanks to
>> Barry and Ying for the reminder.
>
> No worries. I recall encountering a negative count during the development of
> the original patch and eventually realizing it was due to forgetting
> to increment
> the migrated anon folios. Your patch seems to reintroduce the bug I encountered
> back then :-)
Right. I was blind and need a cup of coffee:)
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-12-05 6:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-05 3:53 [PATCH] mm: migrate: drop redundant anonymous statistics for file folios migration Baolin Wang
2024-12-05 5:00 ` Barry Song
2024-12-05 6:06 ` Baolin Wang
2024-12-05 6:33 ` Barry Song
2024-12-05 6:50 ` Baolin Wang
2024-12-05 5:39 ` Huang, Ying
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox