From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E0162FE596 for ; Tue, 17 Feb 2026 21:53:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771365236; cv=none; b=UNR2YiOpHx6KmVQnXSppTOa9XdI4D1unb1WToV8e7PWcFySA2YPfFAtyznc0tc0ATiUhJNB3ErPxmj9pbKVOqduHY8pOo0tzr3qdikprt8O+m7u0YNUsD9wQtlNKg9VpRE0DSLX6pis4EInwqrE2ykb0XZesmcWCvdhktCdNyvg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1771365236; c=relaxed/simple; bh=Vby3374M9lnzfgcnrauQ3GRnMScLxM10VMQm8vPpG8w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=HxKTcVZeupPXv8ppaVCmfzlzoO9lER0qd3JJW/01bmgK/Z+evE7EGVJpeQdEL6/qo91eaPt/+eOhkyf4Tq7C1zh0gmd93iK2LuZ60q9+X4Vd8t+xDZSWyrZdse2T/Rwf/poAPQsQivd9XZ+ZaxROXKNpK3ex9OqPgg7aVqgu4hY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uT5S23n/; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uT5S23n/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A801C19425; Tue, 17 Feb 2026 21:53:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1771365236; bh=Vby3374M9lnzfgcnrauQ3GRnMScLxM10VMQm8vPpG8w=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=uT5S23n/X/Ts82XsxoPXcIY17mciRul7R283oDMQhFRHK6N56YEAKICElByg5n0yv 0IIxcZwkc6tLoeyMNFhXEActUTOzr/xS8WZA8ve2LClKnCl5tLZsOyw0sOybVJZfBb J5t17JdPTBES3l5s59/kbs2UFU13MOKiQro3xOMS7G+UT1ImXgRJYEycjFIMIcezJF lPAImiOdplLrPriKjxiDs8ijwSKVkRBFmkrKDIwRQTqvKHf7h9rEYOs1PgJLdKV5rX 5i0zXpMdf8yt7u6zT7u/74wZ5VONQowxZ1x0M6qkSqXCFy9ThyAdhzQZMHEaPF/wrP KJ1VUi9PCn0gQ== Received: from phl-compute-06.internal (phl-compute-06.internal [10.202.2.46]) by mailfauth.phl.internal (Postfix) with ESMTP id A894EF40068; Tue, 17 Feb 2026 16:53:54 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-06.internal (MEProxy); Tue, 17 Feb 2026 16:53:54 -0500 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddvvddtkeelucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepfffhvfevuffkfhggtggugfgjsehtkeortddttdejnecuhfhrohhmpefmihhrhihl ucfuhhhuthhsvghmrghuuceokhgrsheskhgvrhhnvghlrdhorhhgqeenucggtffrrghtth gvrhhnpefhffeihedtgeekleekgeekieejhfeiiedtveeludejueetkefgteevjeejieet keenucffohhmrghinhepkhgvrhhnvghlrdhorhhgnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepkhhirhhilhhlodhmvghsmhhtphgruhhthhhp vghrshhonhgrlhhithihqdduieduudeivdeiheehqddvkeeggeegjedvkedqkhgrsheppe hkvghrnhgvlhdrohhrghesshhhuhhtvghmohhvrdhnrghmvgdpnhgspghrtghpthhtohep vddvpdhmohguvgepshhmthhpohhuthdprhgtphhtthhopegurghvihgusehkvghrnhgvlh drohhrghdprhgtphhtthhopehhrghofigvnhgthhgrohdvvdesghhmrghilhdrtghomhdp rhgtphhtthhopegrkhhpmheslhhinhhugidqfhhouhhnuggrthhiohhnrdhorhhgpdhrtg hpthhtoheplhhorhgvnhiiohdrshhtohgrkhgvshesohhrrggtlhgvrdgtohhmpdhrtghp thhtoheplhhirghmrdhhohiflhgvthhtsehorhgrtghlvgdrtghomhdprhgtphhtthhope hvsggrsghkrgesshhushgvrdgtiidprhgtphhtthhopehrphhptheskhgvrhhnvghlrdho rhhgpdhrtghpthhtohepshhurhgvnhgssehgohhoghhlvgdrtghomhdprhgtphhtthhope hmhhhotghkohesshhushgvrdgtohhm X-ME-Proxy: Feedback-ID: i10464835:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 17 Feb 2026 16:53:54 -0500 (EST) Date: Tue, 17 Feb 2026 21:53:53 +0000 From: Kiryl Shutsemau To: "David Hildenbrand (Arm)" Cc: Wenchao Hao , Andrew Morton , Lorenzo Stoakes , "Liam R . Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm: Add AnonZero accounting for zero-filled anonymous pages Message-ID: References: <20260214084514.2842745-1-haowenchao22@gmail.com> <419053a2-9784-4051-b73e-5871d3c32be9@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <419053a2-9784-4051-b73e-5871d3c32be9@kernel.org> On Tue, Feb 17, 2026 at 09:29:02PM +0100, David Hildenbrand (Arm) wrote: > On 2/17/26 16:22, Wenchao Hao wrote: > > On Sat, Feb 14, 2026 at 4:45 PM Wenchao Hao wrote: > > > > > > Add kernel command line option "count_zero_page" to track anonymous pages > > > have been allocated and mapped to userspace but zero-filled. > > > > > > This feature is mainly used to debug large folio mechanism, which > > > pre-allocates and map more pages than actually needed, leading to memory > > > waste from unaccessed pages. > > > > > > Export the result in /proc/pid/smaps as "AnonZero" field. > > > > > > Link: https://lore.kernel.org/linux-mm/20260210043456.2137482-1-haowenchao22@gmail.com/ > > > > Sorry for the late reply. We are now on Chinese New Year holiday, so... > > > > The original goal of this patch is to measure memory waste from anonymous > > THPs - pages pre-allocated on fault but never accessed. > > > > On memory-sensitive devices like mobile phones, this helps us make better > > decisions about when and how to enable THP. I think this is useful for > > guiding THP policies, even as a debugging feature. > > > > Let me summarize the discussion so far: > > - Matthew Wilcox questioned the value and raised concerns fork but haven't > > exec path > > - Michal Hocko criticized the inefficiency of scanning zero-filled pages. > > - Kiryl Shutsemau prefers a system-call-based interface. > > - David Hildenbrand acknowledged the value and suggested implementation > > improvements. > > Please correct me if I missed or misrepresented anything. > > > > I suggest we first agree whether this functionality is useful for upstream, > > before discussing implementation details. > > > > Reasons why this should go upstream from me: > > > > - Anonymous THP can introduce real memory waste, but we currently have no > > good way to measure it. > > - With accurate metrics, we can make better THP policy: disable for > > low-utilization cases, or early-unmap to relieve memory pressure and so > > on. This is especially valuable for mobile/embedded devices. > > > > Possible implementations: > > > > 1. A new smaps counter (default-off) to count zero-filled pages. > > 2. A new madvise command like MADV_GET_ZEROPAGE > > 3. A dedicated system call > > I understand Kiyls point about smaps providing too much information users > might not be interested in already. So sorting that out might provide a real > benefit to other users that are only interested in specific stats (e.g., > Rss). You can also limit the range of virtual address space you want to look at. > Providing a system call where one can specify/filter in theory sounds like a > good idea. A syscall implies that one has to write a tool to obtain these > metrics. > > The nice thing about smaps/smaps_rollup is that it can be easily consumed on > any system while debugging. > > I wonder if there could be a way to achieve something similar with a file. > Likely not, but maybe someone reading along can surprise me :) I guess you can open a file write to it what you want to get and then read. It is awkward from shell to keep file descriptor around, but doable. > Otherwise we'd have to go with a tool. A tool might be more ergonomic. To minimize friction, it would be nice to put the tool into util-linux (or whatever trendy Rust-rewrite called), so it would find its way to every machine. Eventually. -- Kiryl Shutsemau / Kirill A. Shutemov