From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Jinjiang Tu <tujinjiang@huawei.com>,
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: Mon, 6 Jul 2026 15:40:39 +0200 [thread overview]
Message-ID: <6ef49a9f-af0c-4bce-8402-16926424ea7a@kernel.org> (raw)
In-Reply-To: <20260706121323.1149847-1-tujinjiang@huawei.com>
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?
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?
--
Cheers,
David
next prev parent reply other threads:[~2026-07-06 13:40 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) [this message]
2026-07-07 2:42 ` Jinjiang Tu
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=6ef49a9f-af0c-4bce-8402-16926424ea7a@kernel.org \
--to=david@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=chengming.zhou@linux.dev \
--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=tujinjiang@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