Re: [PATCH] mm: madvise: fix uneven accounting of psi

From: Johannes Weiner
Date: Wed May 31 2023 - 18:20:05 EST


On Wed, May 31, 2023 at 04:39:34PM +0530, Charan Teja Kalla wrote:
> This patch is tested on Android, Snapdragon SoC with 8Gb RAM, 4GB swap
> mounted on zram which has 2GB of backingdev. The test case involved
> launching some memory hungry apps in an order and do the proactive
> reclaim for the app that went to background using madvise(MADV_PAGEOUT).
> We are seeing ~40% less total values of psi mem some and full when this
> patch is combined with [1].

Does that mean those pages are thrashing, but because you clear their
workingset it isn't detected and reported via psi?

I don't rally get why silencing the thrashing is an improvement.

> [1]https://lore.kernel.org/all/20220214214921.419687-1-hannes@xxxxxxxxxxx/T/#u
>
> Signed-off-by: Charan Teja Kalla <quic_charante@xxxxxxxxxxx>
> ---
> mm/madvise.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/mm/madvise.c b/mm/madvise.c
> index 340125d..3410c39 100644
> --- a/mm/madvise.c
> +++ b/mm/madvise.c
> @@ -409,8 +409,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> if (folio_isolate_lru(folio)) {
> if (folio_test_unevictable(folio))
> folio_putback_lru(folio);
> - else
> + else {
> + folio_clear_workingset(folio);
> list_add(&folio->lru, &folio_list);
> + }
> }
> } else
> folio_deactivate(folio);
> @@ -503,8 +505,10 @@ static int madvise_cold_or_pageout_pte_range(pmd_t *pmd,
> if (folio_isolate_lru(folio)) {
> if (folio_test_unevictable(folio))
> folio_putback_lru(folio);
> - else
> + else {
> + folio_clear_workingset(folio);
> list_add(&folio->lru, &folio_list);
> + }
> }
> } else
> folio_deactivate(folio);
> --
> 2.7.4
>