linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Donet Tom <donettom@linux.ibm.com>
To: Li Zhijian <lizhijian@fujitsu.com>, linux-mm@kvack.org
Cc: Kaiyang Zhao <kaiyang2@cs.cmu.edu>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] mm/vmscan: Accumulate nr_demoted for accurate demotion statistics
Date: Sat, 11 Jan 2025 12:17:17 +0530	[thread overview]
Message-ID: <58f51ab5-6048-4200-8a20-cf6a5c3f4dd9@linux.ibm.com> (raw)
In-Reply-To: <20250111015253.425693-1-lizhijian@fujitsu.com>


On 1/11/25 07:22, Li Zhijian wrote:
> In the shrink_folio_list() function, demote_folio_list() can be called
> 2 times. Currently stat->nr_demoted will only store the last nr_demoted(
> the later nr_demoted is always zero, the former nr_demoted will get lost),
> as a result number of demoted pages is not accurate.
>
> Accumulate the nr_demoted count across multiple calls to
> demote_folio_list(), ensuring accurate reporting of demotion statistics.
>
> Fixes: f77f0c751478 ("mm,memcg: provide per-cgroup counters for NUMA balancing operations")
> Signed-off-by: Li Zhijian <lizhijian@fujitsu.com>
> ---
>
> Cc: Kaiyang Zhao <kaiyang2@cs.cmu.edu>
> Cc: Andrew Morton <akpm@linux-foundation.org>
>
> Kaiyang, I removed you ACKED tag for V1, please review again
> Andrew, Please drop the v1 from the mm-hotfixs-unstable if V2 is
> accepted.
>
> V2:
>    Introudce a local nr_demoted to fix it's counted 2 times by nr_reclaimed wrongly.
> ---
>   mm/vmscan.c | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/mm/vmscan.c b/mm/vmscan.c
> index 9a859b7d18d7..7f0624b98aa8 100644
> --- a/mm/vmscan.c
> +++ b/mm/vmscan.c
> @@ -1053,7 +1053,7 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>   	struct folio_batch free_folios;
>   	LIST_HEAD(ret_folios);
>   	LIST_HEAD(demote_folios);
> -	unsigned int nr_reclaimed = 0;
> +	unsigned int nr_reclaimed = 0, nr_demoted = 0;
>   	unsigned int pgactivate = 0;
>   	bool do_demote_pass;
>   	struct swap_iocb *plug = NULL;
> @@ -1522,8 +1522,9 @@ static unsigned int shrink_folio_list(struct list_head *folio_list,
>   	/* 'folio_list' is always empty here */
>   
>   	/* Migrate folios selected for demotion */
> -	stat->nr_demoted = demote_folio_list(&demote_folios, pgdat);
> -	nr_reclaimed += stat->nr_demoted;
> +	nr_demoted = demote_folio_list(&demote_folios, pgdat);
> +	nr_reclaimed += nr_demoted;
> +	stat->nr_demoted += nr_demoted;
>   	/* Folios that could not be demoted are still in @demote_folios */
>   	if (!list_empty(&demote_folios)) {
>   		/* Folios which weren't demoted go back on @folio_list */
This patch looks good to me.

I tested this patch with the stat fix [1] I could see the demotion 
counts are coming correctly.

pgdemote_kswapd 60517
pgdemote_direct 6737
pgdemote_khugepaged 0


[1] 
https://lore.kernel.org/linux-mm/20250109060540.451261-1-donettom@linux.ibm.com/


Feel free to add

Tested-by: Donet Tom <donettom@linux.ibm.com>
Reviewed-by: Donet Tom <donettom@linux.ibm.com>




      reply	other threads:[~2025-01-11  6:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-11  1:52 Li Zhijian
2025-01-11  6:47 ` Donet Tom [this message]

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=58f51ab5-6048-4200-8a20-cf6a5c3f4dd9@linux.ibm.com \
    --to=donettom@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=kaiyang2@cs.cmu.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=lizhijian@fujitsu.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