From: Barry Song <baohua@kernel.org>
To: Pedro Falcato <pfalcato@suse.de>
Cc: "David Hildenbrand (Arm)" <david@kernel.org>,
Joseph Salisbury <joseph.salisbury@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Chris Li <chrisl@kernel.org>, Kairui Song <kasong@tencent.com>,
Jason Gunthorpe <jgg@ziepe.ca>,
John Hubbard <jhubbard@nvidia.com>, Peter Xu <peterx@redhat.com>,
Kemeng Shi <shikemeng@huaweicloud.com>,
Nhat Pham <nphamcs@gmail.com>, Baoquan He <bhe@redhat.com>,
ljs@kernel.org, linux-mm@kvack.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC] mm: stress-ng --mremap triggers severe lruvec lock contention in populate/unmap paths
Date: Sat, 11 Apr 2026 17:09:02 +0800 [thread overview]
Message-ID: <CAGsJ_4xuGJTiy-aYNuvEVGYdJTQL6-ct_qvZmSXZGdneSfpkWw@mail.gmail.com> (raw)
In-Reply-To: <peuzimkftq4t7kzyfyykwd2juka7z7h6mxsj7itt2fw6nehnvk@pfhser63fpgx>
On Fri, Apr 10, 2026 at 6:30 PM Pedro Falcato <pfalcato@suse.de> wrote:
>
> On Fri, Apr 10, 2026 at 05:59:58AM +0800, Barry Song wrote:
> > On Wed, Apr 8, 2026 at 4:09 PM David Hildenbrand (Arm) <david@kernel.org> wrote:
> > >
> > > >>
> > > >> It was also found that adding '--mremap-numa' changes the behavior
> > > >> substantially:
> > > >
> > > > "assign memory mapped pages to randomly selected NUMA nodes. This is
> > > > disabled for systems that do not support NUMA."
> > > >
> > > > so this is just sharding your lock contention across your NUMA nodes (you
> > > > have an lruvec per node).
> > > >
> > > >>
> > > >> stress-ng --mremap 8192 --mremap-bytes 4K --timeout 30 --mremap-numa
> > > >> --metrics-brief
> > > >>
> > > >> mremap 2570798 29.39 8.06 106.23 87466.50 22494.74
> > > >>
> > > >> So it's possible that either actual swapping, or the mbind(...,
> > > >> MPOL_MF_MOVE) path used by '--mremap-numa', removes most of the excessive
> > > >> system time.
> > > >>
> > > >> Does this look like a known MM scalability issue around short-lived
> > > >> MAP_POPULATE / munmap churn?
> > > >
> > > > Yes. Is this an actual issue on some workload?
> > >
> > > Same thought, it's unclear to me why we should care here. In particular,
> > > when talking about excessive use of zero-filled pages.
> >
> > About 2–3 years ago, I had the impression that we might need
> > separate LRU locks for file and anon. This could reduce
> > contention in real-world scenarios, especially when memcg is
> > not enabled, but I never built a prototype for it.
>
> Honestly, I don't think this would work. You will still contend hard.
> Having a lock for file and a lock for anon just makes two very large
> locks, instead of one gigalarge lock.
This is true, but I feel this might be the low-hanging fruit that should
at least be able to halve the contention, since the implementation would
be small.
>
> I think the real solution is either sharding lruvecs harder[1], percpu-caching
> super-harder, or fully reworking reclaim such that we don't need to maintain
> such a global list.
>
> Alas, maybe we'll get there one day :)
>
> For MADV_POPULATE there might be a straightforward solution, though. Using
> something akin to blk_plug, maintain a per-cpu (or per-task?) list of pages
> that need to be queued. reclaim would drain these lists if needed, or the
> task doing MADV_POPULATE drains them at the end. It should drastically
> reduce lruvec lock traffic (though yes, possibly just another bandaid).
For MADV_POPULATE, I guess your idea can work. But I assume
MADV_POPULATE is not that widely used?
>
> I say "For MADV_POPULATE" simply because I suspect this idea might not be
> useful or effective for regular page faulting.
>
> [1] say, maintain a superpageblock concept that is a lot larger than a pageblock
> (1GB could work? though maybe too small for large machines) and maintain LRU
> ordering between those pages. though later approximating LRU order between
> the superpageblocks is tricky.
We already have this concept in MGLRU, where each zone has its own
LRU lists (but all zones still share the same LRU lock).
With superpageblock, I feel the difficulty is how to balance between
different superpageblocks, and how to compare the aging of folios
across them.
Thanks
Barry
next prev parent reply other threads:[~2026-04-11 9:09 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 20:09 Joseph Salisbury
2026-04-07 21:47 ` Pedro Falcato
2026-04-08 8:09 ` David Hildenbrand (Arm)
2026-04-08 14:27 ` [External] : " Joseph Salisbury
2026-04-09 16:37 ` Haakon Bugge
2026-04-09 17:26 ` Joseph Salisbury
2026-04-10 10:43 ` [External] : " Pedro Falcato
2026-04-09 18:24 ` Lorenzo Stoakes
2026-04-09 21:59 ` Barry Song
2026-04-10 10:30 ` Pedro Falcato
2026-04-11 9:09 ` Barry Song [this message]
2026-04-07 22:44 ` John Hubbard
2026-04-08 0:35 ` Hugh Dickins
2026-04-09 18:03 ` Lorenzo Stoakes
2026-04-09 18:12 ` John Hubbard
2026-04-09 18:20 ` David Hildenbrand (Arm)
2026-04-09 18:47 ` Lorenzo Stoakes
2026-04-09 18:15 ` Haakon Bugge
2026-04-09 18:43 ` Lorenzo Stoakes
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=CAGsJ_4xuGJTiy-aYNuvEVGYdJTQL6-ct_qvZmSXZGdneSfpkWw@mail.gmail.com \
--to=baohua@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=chrisl@kernel.org \
--cc=david@kernel.org \
--cc=jgg@ziepe.ca \
--cc=jhubbard@nvidia.com \
--cc=joseph.salisbury@oracle.com \
--cc=kasong@tencent.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=nphamcs@gmail.com \
--cc=peterx@redhat.com \
--cc=pfalcato@suse.de \
--cc=shikemeng@huaweicloud.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