[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250604114501931NW2by8F85vCd24yqRYHAx@zte.com.cn>
Date: Wed, 4 Jun 2025 11:45:01 +0800 (CST)
From: <xu.xin16@....com.cn>
To: <xialonglong@...inos.cn>
Cc: <akpm@...ux-foundation.org>, <linux-mm@...ck.org>,
<linux-kernel@...r.kernel.org>, <xialonglong@...inos.cn>,
<yang.yang29@....com.cn>, <wang.yaxin@....com.cn>
Subject: Re: [PATCH 1/2] mm/ksm: calculate ksm_process_profit more accurately
> The general_profit_show() only considers ksm_pages_sharing,
> whereas ksm_process_profit() accounts for both ksm_pages_sharing
> and ksm_pages_shared for each process. This discrepancy leads to
> the sum of ksm_process_profit() across all processes not being equal
> to general_profit_show().
>
> Fixes: 7609385337a4 ("ksm: count ksm merging pages for each process")
> Signed-off-by: Longlong Xia <xialonglong@...inos.cn>
> ---
> mm/ksm.c | 20 ++++++++------------
> 1 file changed, 8 insertions(+), 12 deletions(-)
Thanks for you report, but we'd better not change the definition of ksm_merging_pages which means
all pages involved in ksm merging (pages_sharing + pages_shared), and Do not rename the existing
of interface, which breaks user-space tools.
If we reallt want a more pricise profit of a process , I suggest:
- 1) Add a variable 'ksm_pages_sharing' in mm_struct for processes.
- 2) Refine the implementation of ksm_process_profit().
Thanks~
>
> diff --git a/mm/ksm.c b/mm/ksm.c
> index 8583fb91ef13..fa4e1618b671 100644
> --- a/mm/ksm.c
> +++ b/mm/ksm.c
> @@ -824,12 +824,10 @@ static void remove_node_from_stable_tree(struct ksm_stable_node *stable_node)
> hlist_for_each_entry(rmap_item, &stable_node->hlist, hlist) {
> if (rmap_item->hlist.next) {
> ksm_pages_sharing--;
> + rmap_item->mm->ksm_merging_pages--;
> trace_ksm_remove_rmap_item(stable_node->kpfn, rmap_item, rmap_item->mm);
> - } else {
> + } else
> ksm_pages_shared--;
> - }
> -
> - rmap_item->mm->ksm_merging_pages--;
Powered by blists - more mailing lists