linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Chengming Zhou <chengming.zhou@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@redhat.com>,
	Stefan Roesch <shr@devkernel.io>, xu xin <xu.xin16@zte.com.cn>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	zhouchengming@bytedance.com
Subject: Re: [PATCH 1/4] mm/ksm: fix ksm_pages_scanned accounting
Date: Wed, 8 May 2024 18:35:06 +0800	[thread overview]
Message-ID: <36168dfd-bdfa-42cd-965a-f7a0e108108e@linux.dev> (raw)
In-Reply-To: <20240508-b4-ksm-counters-v1-1-e2a9b13f70c5@linux.dev>

On 2024/5/8 17:55, Chengming Zhou wrote:
> During testing, I found ksm_pages_scanned is unchanged although the
> scan_get_next_rmap_item() did return valid rmap_item that is not NULL.
> 
> The reason is the scan_get_next_rmap_item() will return NULL after
> a full scan, so ksm_do_scan() just return without accounting of the
> ksm_pages_scanned.
> 
> Fix it by just putting ksm_pages_scanned accounting in that loop,
> and it will be accounted more timely if that loop would last for
> a long time.
> 

Fixes: b348b5fe2b5f ("mm/ksm: add pages scanned metric")

> Signed-off-by: Chengming Zhou <chengming.zhou@linux.dev>
> ---
>  mm/ksm.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/mm/ksm.c b/mm/ksm.c
> index e1034bf1c937..0f9c491552ff 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -2753,18 +2753,16 @@ static void ksm_do_scan(unsigned int scan_npages)
>  {
>  	struct ksm_rmap_item *rmap_item;
>  	struct page *page;
> -	unsigned int npages = scan_npages;
>  
> -	while (npages-- && likely(!freezing(current))) {
> +	while (scan_npages-- && likely(!freezing(current))) {
>  		cond_resched();
>  		rmap_item = scan_get_next_rmap_item(&page);
>  		if (!rmap_item)
>  			return;
>  		cmp_and_merge_page(page, rmap_item);
>  		put_page(page);
> +		ksm_pages_scanned++;
>  	}
> -
> -	ksm_pages_scanned += scan_npages - npages;
>  }
>  
>  static int ksmd_should_run(void)
> 


  reply	other threads:[~2024-05-08 10:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-08  9:55 [PATCH 0/4] mm/ksm: fix some accounting problems Chengming Zhou
2024-05-08  9:55 ` [PATCH 1/4] mm/ksm: fix ksm_pages_scanned accounting Chengming Zhou
2024-05-08 10:35   ` Chengming Zhou [this message]
2024-05-08 12:32     ` David Hildenbrand
2024-05-08  9:55 ` [PATCH 2/4] mm/ksm: fix ksm_zero_pages accounting Chengming Zhou
2024-05-08 10:37   ` Chengming Zhou
2024-05-08 12:36   ` David Hildenbrand
2024-05-08 13:52     ` Chengming Zhou
2024-05-08  9:55 ` [PATCH 3/4] mm/ksm: union hlist_node with list_head in struct ksm_stable_node Chengming Zhou
2024-05-08  9:55 ` [PATCH 4/4] mm/ksm: calculate general_profit more accurately Chengming Zhou
2024-05-08 10:24 ` [PATCH 0/4] mm/ksm: fix some accounting problems David Hildenbrand
2024-05-08 10:28   ` Chengming Zhou

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=36168dfd-bdfa-42cd-965a-f7a0e108108e@linux.dev \
    --to=chengming.zhou@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=david@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shr@devkernel.io \
    --cc=xu.xin16@zte.com.cn \
    --cc=zhouchengming@bytedance.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