Re: [PATCH v2] memcontrol: only transfer the memcg data for migration

From: Nhat Pham
Date: Wed Oct 04 2023 - 15:53:17 EST


On Wed, Oct 4, 2023 at 12:46 PM Johannes Weiner <hannes@xxxxxxxxxxx> wrote:
>
> On Wed, Oct 04, 2023 at 12:36:22PM -0700, Nhat Pham wrote:
> > For most migration use cases, only transfer the memcg data from the old
> > folio to the new folio, and clear the old folio's memcg data. No
> > charging and uncharging will be done.
> >
> > This shaves off some work on the migration path, and avoids the
> > temporary double charging of a folio during its migration.
> >
> > The only exception is replace_page_cache_folio(), which will use the old
> > mem_cgroup_migrate() (now renamed to mem_cgroup_replace_folio). In that
> > context, the isolation of the old page isn't quite as thorough as with
> > migration, so we cannot use our new implementation directly.
> >
> > This patch is the result of the following discussion on the new hugetlb
> > memcg accounting behavior:
> >
> > https://lore.kernel.org/lkml/20231003171329.GB314430@monkey/
> >
> > This should be added as the second prep patch in the following series:
> > https://lore.kernel.org/all/20231003001828.2554080-1-nphamcs@xxxxxxxxx/
> > (hugetlb memcg accounting)
> >
> > and should go right before the following patch:
> > hugetlb: memcg: account hugetlb-backed memory in memory controller
> >
> > Reported-by: Mike Kravetz <mike.kravetz@xxxxxxxxxx>
> > Closes: https://lore.kernel.org/lkml/20231003171329.GB314430@monkey/
>
> These two tags shouldn't be here, but in the fixlet instead. This is
> the dependency patch. Otherwise looks good to me:
>
> > Suggested-by: Johannes Weiner <hannes@xxxxxxxxxxx>
> > Signed-off-by: Nhat Pham <nphamcs@xxxxxxxxx>
>
> Acked-by: Johannes Weiner <hannes@xxxxxxxxxxx>

Thanks for the review, Johannes!