All of lore.kernel.org
 help / color / mirror / Atom feed
From: Johannes Weiner <hannes@cmpxchg.org>
To: liuye <liuye@kylinos.cn>
Cc: Ye Liu <ye.liu@linux.dev>,
	"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	David Hildenbrand <david@kernel.org>,
	"Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	Suren Baghdasaryan <surenb@google.com>,
	Michal Hocko <mhocko@suse.com>, Kairui Song <kasong@tencent.com>,
	Qi Zheng <qi.zheng@linux.dev>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	Barry Song <baohua@kernel.org>,
	Axel Rasmussen <axelrasmussen@google.com>,
	Yuanchu Xie <yuanchu@google.com>, Wei Xu <weixugc@google.com>,
	Zi Yan <ziy@nvidia.com>,
	Baolin Wang <baolin.wang@linux.alibaba.com>,
	Nico Pache <npache@redhat.com>,
	Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
	Lance Yang <lance.yang@linux.dev>,
	Usama Arif <usama.arif@linux.dev>,
	driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH] mm/thp: expose deferred split folio memory usage in meminfo
Date: Fri, 17 Jul 2026 12:29:09 +0200	[thread overview]
Message-ID: <20260717102909.GA6843@cmpxchg.org> (raw)
In-Reply-To: <70294b26-86e1-4de0-832f-d5cb488cdb3e@kylinos.cn>

Hello,

On Fri, Jul 17, 2026 at 05:38:10PM +0800, liuye wrote:
> 
> 在 2026/7/17 17:24, Ye Liu 写道:
> >
> > 在 2026/7/17 16:08, Lorenzo Stoakes (ARM) 写道:
> >> +cc Johannes
> >>
> >> On Fri, Jul 17, 2026 at 02:30:22PM +0800, Ye Liu wrote:
> >>> From: Ye Liu <liuye@kylinos.cn>
> >>>
> >>> Folios on the deferred split list hold physical memory that is
> >>> invisible in meminfo. When a THP becomes partially mapped, the
> >>> unmapped pages are removed from AnonPages but remain physically
> >>> allocated until the shrinker splits the folio. This creates a
> >>> memory accounting gap where used memory cannot be attributed to
> >>> any meminfo field.
> >> Is this really that much of an issue? You're not giving any use cases here.
> >>
> >> What real-world use case motivated this?
> >>
> > I have indeed encountered this situation in a customer environment,                           

We have run into this before as well. It's not super
rare. Applications do partial unmaps or protection changes with no
awareness for THPs. The issue is likely to stick around with legacy
software for some time.

Do note that all information is there if you know how to look for
it. But it is cumbersome and somewhat inconsistent, so I'm not opposed
to fixing it:

> > but the environment is complex, and I cannot clearly explain why this memory                  
> > black hole occurs in that scenario.                                                           
> > However, I will provide an example to reproduce it below.                                     
> > Use case: The system has 100GB of memory. A user-space program requests 80GB of memory.       
> > For each 2MB block, only one page is retained, and the mapping of all other pages is unmapped,
> > while the process continues to run.                                                           
> > You'll find that in meminfo, MemFree: only 12GB remains,                                      
> > but the process actually uses very little memory.                                             
> > This creates a memory black hole situation.                                                   
> > Below is the test program I used, from AI.                                                    
> >
> 
> ps -p $(pgrep -d, test) -o pid,comm,%mem,rss,vsz
>     PID COMMAND         %MEM   RSS    VSZ
>    9358 test             0.1 165220 166032
> 
> 
> MemTotal:       101606276 kB
> MemFree:        13172092 kB
> MemAvailable:   13569668 kB
> Buffers:            5352 kB
> Cached:          1169520 kB
> SwapCached:            0 kB
> Active:         84730404 kB
> Inactive:        1129792 kB
> Active(anon):   84730404 kB

This shows actually allocated anon+shmem.

> Inactive(anon):        0 kB
> Active(file):          0 kB
> Inactive(file):  1129792 kB
> Unevictable:        6192 kB
> Mlocked:              32 kB
> SwapTotal:       4194300 kB
> SwapFree:        4194300 kB
> Zswap:                 0 kB
> Zswapped:              0 kB
> Dirty:                24 kB
> Writeback:             0 kB
> AnonPages:        969280 kB

This shows anon *mapped*.

> Mapped:           308848 kB
> Shmem:             45076 kB

This shows that your (in)active anon *isn't* driven by shmem.

> KReclaimable:      96144 kB
> Slab:             269540 kB
> SReclaimable:      96144 kB
> SUnreclaim:       173396 kB
> KernelStack:       27584 kB
> PageTables:       187408 kB
> SecPageTables:         0 kB
> NFS_Unstable:          0 kB
> Bounce:                0 kB
> WritebackTmp:          0 kB
> CommitLimit:    54997436 kB
> Committed_AS:    6628776 kB
> VmallocTotal:   261087232 kB
> VmallocUsed:       38696 kB
> VmallocChunk:          0 kB
> Percpu:            42800 kB
> HardwareCorrupted:     0 kB
> AnonHugePages:    413696 kB

This shows anon pmd-mapped.

> ShmemHugePages:        0 kB
> ShmemPmdMapped:        0 kB
> FileHugePages:    172032 kB
> FilePmdMapped:     28672 kB

This shows both allocated huge pages and the pmd-mapped portion.

So you *can* work it out by looking at the LRU ((in)active) and
cross-checking the shmem position. But it is awkward, granted.

IMO if there is a case to be made, it's doing the same split we do for
file and shmem - AnonHugePages (allocated) and AnonPmdMapped.

  parent reply	other threads:[~2026-07-17 10:29 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  6:30 [PATCH] mm/thp: expose deferred split folio memory usage in meminfo Ye Liu
2026-07-17  8:08 ` Lorenzo Stoakes (ARM)
2026-07-17  9:24   ` Ye Liu
2026-07-17  9:38     ` liuye
2026-07-17  9:47       ` Lorenzo Stoakes (ARM)
2026-07-17 10:29       ` Johannes Weiner [this message]
2026-07-17  8:37 ` David Hildenbrand (Arm)
2026-07-17  8:47   ` Lorenzo Stoakes (ARM)
2026-07-17  9:31   ` Ye Liu
2026-07-17  9:33     ` David Hildenbrand (Arm)
2026-07-17  9:48       ` Lorenzo Stoakes (ARM)
2026-07-17  9:54         ` Ye Liu
2026-07-17 10:29           ` David Hildenbrand (Arm)
2026-07-17 10:29     ` Vlastimil Babka (SUSE)

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=20260717102909.GA6843@cmpxchg.org \
    --to=hannes@cmpxchg.org \
    --cc=akpm@linux-foundation.org \
    --cc=axelrasmussen@google.com \
    --cc=baohua@kernel.org \
    --cc=baolin.wang@linux.alibaba.com \
    --cc=dakr@kernel.org \
    --cc=david@kernel.org \
    --cc=dev.jain@arm.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gregkh@linuxfoundation.org \
    --cc=kasong@tencent.com \
    --cc=lance.yang@linux.dev \
    --cc=liam@infradead.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=liuye@kylinos.cn \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=npache@redhat.com \
    --cc=qi.zheng@linux.dev \
    --cc=rafael@kernel.org \
    --cc=rppt@kernel.org \
    --cc=ryan.roberts@arm.com \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=usama.arif@linux.dev \
    --cc=vbabka@kernel.org \
    --cc=weixugc@google.com \
    --cc=ye.liu@linux.dev \
    --cc=yuanchu@google.com \
    --cc=ziy@nvidia.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.