From: Jinjiang Tu <tujinjiang@huawei.com>
To: "David Hildenbrand (Arm)" <david@kernel.org>,
<akpm@linux-foundation.org>, <liam@infradead.org>,
<ljs@kernel.org>, <vbabka@kernel.org>, <jannh@google.com>,
<pfalcato@suse.de>, <xu.xin16@zte.com.cn>,
<chengming.zhou@linux.dev>, <linux-mm@kvack.org>,
<linux-fsdevel@vger.kernel.org>
Cc: <wangkefeng.wang@huawei.com>, <sunnanyong@huawei.com>
Subject: Re: [PATCH] fs/proc/task_mmu: count KSM-placed zero pages in smaps
Date: Tue, 7 Jul 2026 10:42:14 +0800 [thread overview]
Message-ID: <3aa50eea-ad23-4b19-9b31-a111dd5efb71@huawei.com> (raw)
In-Reply-To: <6ef49a9f-af0c-4bce-8402-16926424ea7a@kernel.org>
在 2026/7/6 21:40, David Hildenbrand (Arm) 写道:
> On 7/6/26 14:13, Jinjiang Tu wrote:
>> When KSM deduplicates a page to the kernel zero page (i.e. when
>> /sys/kernel/mm/ksm/use_zero_pages=1), it places a zero PTE with the dirty
>> bit set. vm_normal_page() returns NULL for such PTEs, so smaps_pte_entry()
>> bails out before reaching smaps_account() and these pages are never counted
>> into mss->ksm. As a result /proc/<pid>/smaps and smaps_rollup report a KSM
>> value of 0 even though the region is fully merged.
>>
>> Count KSM-placed zero pages directly in smaps_pte_entry() using
>> is_ksm_zero_pte().
> Hm.
>
> We do expose "ksm_zero_pages" in /proc/<pid>/ksm_stat for calculating the KSM
> profit.
>
> Why would we want to expose it here as KSM pages?
I wasanalyzing the KSM profit of a process comes from which VMAs. However,
smaps does not include the savings from ksm_zero_pages, make me fail to
analyze.
> An application will notice the difference between "zeropage enabled vs.
> disabled" either way because we'll also not account zerpages towards e.g.,
> "Anonymous".
>
> So faking that something consumes memory when it actually doesn't consume memory
> is wrong?
next prev parent reply other threads:[~2026-07-07 2:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-06 12:13 [PATCH] fs/proc/task_mmu: count KSM-placed zero pages in smaps Jinjiang Tu
2026-07-06 13:40 ` David Hildenbrand (Arm)
2026-07-07 2:42 ` Jinjiang Tu [this message]
2026-07-07 2:49 ` Jinjiang Tu
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=3aa50eea-ad23-4b19-9b31-a111dd5efb71@huawei.com \
--to=tujinjiang@huawei.com \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--cc=david@kernel.org \
--cc=jannh@google.com \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=pfalcato@suse.de \
--cc=sunnanyong@huawei.com \
--cc=vbabka@kernel.org \
--cc=wangkefeng.wang@huawei.com \
--cc=xu.xin16@zte.com.cn \
/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