[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAGsJ_4z5hs5ehF=kq+CSHiQDUB=tu=Qy6X6fxhK6Qn4qg-X3yw@mail.gmail.com>
Date: Sun, 11 Aug 2024 21:22:21 +1200
From: Barry Song <21cnbao@...il.com>
To: David Hildenbrand <david@...hat.com>
Cc: akpm@...ux-foundation.org, baolin.wang@...ux.alibaba.com,
chrisl@...nel.org, hanchuanhua@...o.com, ioworker0@...il.com,
kaleshsingh@...gle.com, kasong@...cent.com, linux-kernel@...r.kernel.org,
linux-mm@...ck.org, ryan.roberts@....com, v-songbaohua@...o.com,
ziy@...dia.com
Subject: Re: [PATCH RFC 1/2] mm: collect the number of anon large folios
On Sun, Aug 11, 2024 at 8:51 PM David Hildenbrand <david@...hat.com> wrote:
>
> > the correct place should be:
> >
> > @@ -1329,6 +1326,10 @@ static int migrate_folio_move(free_folio_t
> > put_new_folio, unsigned long private,
> > if (anon_vma)
> > put_anon_vma(anon_vma);
> > folio_unlock(src);
> > +
> > + if (folio_test_anon(src))
> > + mod_mthp_stat(folio_order(src), MTHP_STAT_NR_ANON, 1);
> > +
> > migrate_folio_done(src, reason);
> >
> > return rc;
> >
> > Without this modification in migration code, my tests fail, anon_num can
> > become negative.
>
> I was wondering if we should do it in __folio_migrate_mapping().
>
> There, we set newfolio->mapping.
Correct! To handle cases where the destination might not be migrated to but
could be put or freed, migrate_folio_undo_dst() will be called to release the
destination earlier. It's better to simply place the count where the
anon mapping
is set and cleared.
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -423,6 +423,8 @@ static int __folio_migrate_mapping(struct
address_space *mapping,
/* No turning back from here */
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);
if (folio_test_swapbacked(folio))
__folio_set_swapbacked(newfolio);
@@ -446,6 +448,9 @@ static int __folio_migrate_mapping(struct
address_space *mapping,
* no turning back from here.
*/
newfolio->index = folio->index;
+
+ if (folio_test_anon(folio) && folio_test_large(folio))
+ mod_mthp_stat(folio_order(folio), MTHP_STAT_NR_ANON, 1);
newfolio->mapping = folio->mapping;
folio_ref_add(newfolio, nr); /* add cache reference */
if (folio_test_swapbacked(folio)) {
>
> --
> Cheers,
>
> David / dhildenb
>
Powered by blists - more mailing lists