linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Barry Song <21cnbao@gmail.com>
To: David Hildenbrand <david@redhat.com>
Cc: akpm@linux-foundation.org, baolin.wang@linux.alibaba.com,
	 chrisl@kernel.org, hanchuanhua@oppo.com, ioworker0@gmail.com,
	 kaleshsingh@google.com, kasong@tencent.com,
	linux-kernel@vger.kernel.org,  linux-mm@kvack.org,
	ryan.roberts@arm.com, v-songbaohua@oppo.com,  ziy@nvidia.com
Subject: Re: [PATCH RFC 1/2] mm: collect the number of anon large folios
Date: Sun, 11 Aug 2024 21:22:21 +1200	[thread overview]
Message-ID: <CAGsJ_4z5hs5ehF=kq+CSHiQDUB=tu=Qy6X6fxhK6Qn4qg-X3yw@mail.gmail.com> (raw)
In-Reply-To: <fae2def0-918a-495b-a89b-3a8eedd44b1f@redhat.com>

On Sun, Aug 11, 2024 at 8:51 PM David Hildenbrand <david@redhat.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
>


  reply	other threads:[~2024-08-11  9:22 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <41b49313-5804-46ba-9e1d-358b079274cd@redhat.com>
2024-08-09  7:04 ` Barry Song
2024-08-09  7:22   ` David Hildenbrand
2024-08-11  5:20     ` Barry Song
2024-08-11  6:54       ` Barry Song
2024-08-11  8:51         ` David Hildenbrand
2024-08-11  9:22           ` Barry Song [this message]
     [not found] <20240808010457.228753-1-21cnbao@gmail.com>
     [not found] ` <20240808010457.228753-2-21cnbao@gmail.com>
2024-08-09  8:13   ` Ryan Roberts
2024-08-09  8:27     ` Ryan Roberts
2024-08-09  8:40       ` Barry Song
2024-08-09  8:42       ` David Hildenbrand
2024-08-09  8:58         ` David Hildenbrand
2024-08-09  9:05           ` Ryan Roberts
2024-08-09  9:22             ` David Hildenbrand
2024-08-11  8:13               ` Barry Song
2024-08-09  8:39     ` David Hildenbrand
2024-08-09  9:00       ` Ryan Roberts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAGsJ_4z5hs5ehF=kq+CSHiQDUB=tu=Qy6X6fxhK6Qn4qg-X3yw@mail.gmail.com' \
    --to=21cnbao@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=chrisl@kernel.org \
    --cc=david@redhat.com \
    --cc=hanchuanhua@oppo.com \
    --cc=ioworker0@gmail.com \
    --cc=kaleshsingh@google.com \
    --cc=kasong@tencent.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ryan.roberts@arm.com \
    --cc=v-songbaohua@oppo.com \
    --cc=ziy@nvidia.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox