From: Nhat Pham <nphamcs@gmail.com>
To: Jingxiang Zeng <jingxiangzeng.cas@gmail.com>
Cc: linux-mm@kvack.org, akpm@linux-foundation.org,
cgroups@vger.kernel.org, hannes@cmpxchg.org,
linuszeng@tencent.com, linux-kernel@vger.kernel.org,
mhocko@kernel.org, muchun.song@linux.dev,
roman.gushchin@linux.dev, shakeel.butt@linux.dev,
yosryahmed@google.com
Subject: Re: [PATCH V2] mm/memcontrol: add per-memcg pgpgin/pswpin counter
Date: Fri, 11 Oct 2024 16:01:45 -0400 [thread overview]
Message-ID: <CAKEwX=N104p+yJvZEfG0B4kEURjc6CLzY1NqM09cxDFfHBzdVA@mail.gmail.com> (raw)
In-Reply-To: <20240913084453.3605621-1-jingxiangzeng.cas@gmail.com>
On Fri, Sep 13, 2024 at 8:21 AM Jingxiang Zeng
<jingxiangzeng.cas@gmail.com> wrote:
>
> From: Jingxiang Zeng <linuszeng@tencent.com>
>
> In proactive memory reclamation scenarios, it is necessary to estimate the
> pswpin and pswpout metrics of the cgroup to determine whether to continue
> reclaiming anonymous pages in the current batch. This patch will collect
> these metrics and expose them.
+1 - this is also useful for zswap shrinker enablement, after which an
anon page can be loaded back in either from swap or zswap.
Differentiating these two situations helps a lot with performance
regression diagnostics.
We have host level metrics, but they become less useful when we
combine workloads with different characteristics in the same host.
>
> Link: https://lkml.kernel.org/r/20240830082244.156923-1-jingxiangzeng.cas@gmail.com
> Signed-off-by: Jingxiang Zeng <linuszeng@tencent.com>
> Cc: Johannes Weiner <hannes@cmpxchg.org>
> Cc: Michal Hocko <mhocko@kernel.org>
> Cc: Muchun Song <muchun.song@linux.dev>
> Cc: Roman Gushchin <roman.gushchin@linux.dev>
> Cc: Shakeel Butt <shakeel.butt@linux.dev>
> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> ---
> mm/memcontrol.c | 2 ++
> mm/page_io.c | 4 ++++
> 2 files changed, 6 insertions(+)
>
> diff --git a/mm/memcontrol.c b/mm/memcontrol.c
> index 6efbfc9399d0..dbc1d43a5c4c 100644
> --- a/mm/memcontrol.c
> +++ b/mm/memcontrol.c
> @@ -418,6 +418,8 @@ static const unsigned int memcg_vm_event_stat[] = {
> PGPGIN,
> PGPGOUT,
> #endif
> + PSWPIN,
> + PSWPOUT,
> PGSCAN_KSWAPD,
> PGSCAN_DIRECT,
> PGSCAN_KHUGEPAGED,
> diff --git a/mm/page_io.c b/mm/page_io.c
> index b6f1519d63b0..4bc77d1c6bfa 100644
> --- a/mm/page_io.c
> +++ b/mm/page_io.c
> @@ -310,6 +310,7 @@ static inline void count_swpout_vm_event(struct folio *folio)
> }
> count_mthp_stat(folio_order(folio), MTHP_STAT_SWPOUT);
> #endif
> + count_memcg_folio_events(folio, PSWPOUT, folio_nr_pages(folio));
> count_vm_events(PSWPOUT, folio_nr_pages(folio));
> }
>
> @@ -505,6 +506,7 @@ static void sio_read_complete(struct kiocb *iocb, long ret)
> for (p = 0; p < sio->pages; p++) {
> struct folio *folio = page_folio(sio->bvec[p].bv_page);
>
> + count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
> folio_mark_uptodate(folio);
> folio_unlock(folio);
> }
> @@ -588,6 +590,7 @@ static void swap_read_folio_bdev_sync(struct folio *folio,
> * attempt to access it in the page fault retry time check.
> */
> get_task_struct(current);
> + count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
> count_vm_event(PSWPIN);
> submit_bio_wait(&bio);
> __end_swap_bio_read(&bio);
> @@ -603,6 +606,7 @@ static void swap_read_folio_bdev_async(struct folio *folio,
> bio->bi_iter.bi_sector = swap_folio_sector(folio);
> bio->bi_end_io = end_swap_bio_read;
> bio_add_folio_nofail(bio, folio, folio_size(folio), 0);
> + count_memcg_folio_events(folio, PSWPIN, folio_nr_pages(folio));
> count_vm_event(PSWPIN);
Not related to this patch, but why does the global stats not take into
account large folios here... `count_vm_event(PSWPIN);`?
Acked-by: Nhat Pham <nphamcs@gmail.com>
next prev parent reply other threads:[~2024-10-11 20:02 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <Jingxiang Zeng <linuszeng@tencent.com>
2024-09-13 8:44 ` Jingxiang Zeng
2024-09-16 7:41 ` Andrew Morton
2024-09-21 7:51 ` jingxiang zeng
2024-10-11 20:01 ` Nhat Pham [this message]
2024-09-13 8:45 ` [PATCH V2] mm/vmscan: wake up flushers conditionally to avoid cgroup OOM Jingxiang Zeng
2024-09-16 16:11 ` Wei Xu
2024-09-23 1:44 ` jingxiang zeng
2024-09-25 0:41 ` Chris Li
2024-09-24 12:13 ` [PATCH V3] " Jingxiang Zeng
2024-09-25 2:07 ` Chris Li
2024-09-29 11:26 ` [PATCH] [PATCH v4] " Jingxiang Zeng
2024-09-29 11:47 ` jingxiang zeng
2024-09-29 11:30 ` Jingxiang Zeng
2024-10-08 1:56 ` [RESEND][PATCH " Jingxiang Zeng
2024-10-08 2:15 ` Andrew Morton
2024-10-08 3:26 ` Wei Xu
2024-10-09 4:52 ` jingxiang zeng
2024-10-09 6:21 ` Wei Xu
2024-10-08 17:12 ` Chris Li
2024-10-09 5:29 ` jingxiang zeng
2024-10-09 5:43 ` jingxiang zeng
2024-10-09 5:34 ` jingxiang zeng
2024-10-18 5:29 ` [PATCH v5] " Jingxiang Zeng
2024-10-18 6:36 ` Wei Xu
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='CAKEwX=N104p+yJvZEfG0B4kEURjc6CLzY1NqM09cxDFfHBzdVA@mail.gmail.com' \
--to=nphamcs@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=cgroups@vger.kernel.org \
--cc=hannes@cmpxchg.org \
--cc=jingxiangzeng.cas@gmail.com \
--cc=linuszeng@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=roman.gushchin@linux.dev \
--cc=shakeel.butt@linux.dev \
--cc=yosryahmed@google.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