mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ridong Chen <ridong.chen@linux.dev>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: David Hildenbrand <david@kernel.org>, Zi Yan <ziy@nvidia.com>,
	Matthew Brost <matthew.brost@intel.com>,
	Joshua Hahn <joshua.hahnjy@gmail.com>,
	Byungchul Park <byungchul@sk.com>,
	Gregory Price <gourry@gourry.net>,
	Ying Huang <ying.huang@linux.alibaba.com>,
	Alistair Popple <apopple@nvidia.com>, Boris Burkov <boris@bur.io>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	Shivank Garg <shivankg@amd.com>,
	Ridong Chen <chenridong@xiaomi.com>
Subject: Re: [PATCH mm-new] mm/migrate: move NR_KERNEL_FILE_PAGES on cross-node migration
Date: Fri, 30 Oct 2026 09:42:45 +0800	[thread overview]
Message-ID: <eed3526e-9cda-45da-98f6-6473238ce4ef@linux.dev> (raw)
In-Reply-To: <20261029180326.84ae7b2c1f63f016c66bd28e@linux-foundation.org>



On 10/30/2026 9:03 AM, Andrew Morton wrote:
> On Tue, 27 Oct 2026 12:32:14 +0800 Ridong Chen <ridong.chen@linux.dev> wrote:
> 
>> From: Ridong Chen <chenridong@xiaomi.com>
>>
>> NR_KERNEL_FILE_PAGES counts page cache folios of mappings flagged
>> AS_KERNEL_FILE (currently the btrfs btree inode).  It is a per-node
>> counter: filemap_add_folio() adds to folio_pgdat() of the new folio and
>> filemap_unaccount_folio() subtracts from folio_pgdat() of the folio
>> being removed.
>>
>> __folio_migrate_mapping() does not move it when such a folio is
>> migrated to another node, so the source node keeps the count forever
>> and the destination node underflows once the folio is freed.  btree
>> folios are migratable through btree_migrate_folio(), so demotion,
>> DAMON-based migration (DAMOS_MIGRATE_{HOT,COLD}) or memory offlining
>> all hit this.
>>
>> Reproducer, on a QEMU guest with two memory tiers (node0 is DRAM with
>> all CPUs, node1 is a CPU-less slower node described via HMAT) and
>> /sys/kernel/mm/numa/demotion_enabled set:
>>
>>    1. mount a btrfs and create 20000 empty files, so that btree folios
>>       are cached on node0;
>>    2. echo 2G > /sys/devices/system/node/node0/reclaim, which demotes
>>       them to node1;
>>    3. umount and drop caches.
>>
>> nr_kernel_file_pages in /sys/devices/system/node/nodeN/vmstat after
>> each step:
>>
>>                    without this patch     with this patch
>>                     node0     node1       node0     node1
>>    1. cached         1868         0        1868         0
>>    2. demoted        1868         0          36      1832
>>    3. dropped        1832         0 (*)       0         0
>>
>>    (*) the counter has underflowed to -1832; negative values read as 0.
>>
>> The global value in /proc/vmstat is 0 after step 3 in both cases.
>>
>> Move it together with the other node-keyed page cache counters.  It is
>> a node-only counter, so use the node accessor, matching how it is
>> accounted elsewhere.  Interrupts are disabled here, as for the zone
>> counters below.
>>
>> This was pointed out by Shivank while reviewing the NR_FILE_THPS fix
>> for the same function.
>>
> 
> Thanks.
> 
> This and your "mm/migrate: move NR_FILE_THPS on cross-node migration"
> "only" address accounting errors, but a bug is a bug and these bugs
> might mess up people's memory-monitoring and NUMA-management tools.  So
> I think cc:stable.
> 
> What do people think?

Agreed, thanks.

-- 
Best regards
Ridong


  reply	other threads:[~2026-10-30  1:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-27  4:32 Ridong Chen
2026-10-27  4:59 ` Garg, Shivank
2026-10-27 14:49 ` Zi Yan
2026-10-28  8:36 ` David Hildenbrand (Arm)
2026-10-30  1:03 ` Andrew Morton
2026-10-30  1:42   ` Ridong Chen [this message]
2026-10-30  2:02   ` Shakeel Butt
2026-10-30  2:02 ` Shakeel Butt

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=eed3526e-9cda-45da-98f6-6473238ce4ef@linux.dev \
    --to=ridong.chen@linux.dev \
    --cc=akpm@linux-foundation.org \
    --cc=apopple@nvidia.com \
    --cc=boris@bur.io \
    --cc=byungchul@sk.com \
    --cc=chenridong@xiaomi.com \
    --cc=david@kernel.org \
    --cc=gourry@gourry.net \
    --cc=joshua.hahnjy@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=matthew.brost@intel.com \
    --cc=shakeel.butt@linux.dev \
    --cc=shivankg@amd.com \
    --cc=ying.huang@linux.alibaba.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®