From: Matthew Wilcox <willy@infradead.org>
To: Peter Xu <peterx@redhat.com>
Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org,
Andrew Morton <akpm@linux-foundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Lokesh Gidra <lokeshgidra@google.com>,
"Liam R . Howlett" <Liam.Howlett@oracle.com>,
Alistair Popple <apopple@nvidia.com>
Subject: Re: [PATCH] mm: Always sanity check anon_vma first for per-vma locks
Date: Thu, 11 Apr 2024 15:50:54 +0100 [thread overview]
Message-ID: <Zhf4zqsfkz1XCwBN@casper.infradead.org> (raw)
In-Reply-To: <ZhcstFcjOuOmr0wx@x1n>
On Wed, Apr 10, 2024 at 08:20:04PM -0400, Peter Xu wrote:
> On Thu, Apr 11, 2024 at 12:59:09AM +0100, Matthew Wilcox wrote:
> > On Wed, Apr 10, 2024 at 05:23:18PM -0400, Peter Xu wrote:
> > > On Wed, Apr 10, 2024 at 10:10:45PM +0100, Matthew Wilcox wrote:
> > > > > I can do some tests later today or tomorrow. Any suggestion you have on
> > > > > amplifying such effect that you have concern with?
> > > >
> > > > 8 socket NUMA system, 800MB text segment, 10,000 threads. No, I'm not
> > > > joking, that's a real customer workload.
> > >
> > > Well, I believe you, but even with this, that's a total of 800MB memory on
> > > a giant moster system... probably just to fault in once.
> > >
> > > And even before we talk about that into details.. we're talking about such
> > > giant program running acorss hundreds of cores with hundreds of MB text,
> > > then... hasn't the program developer already considered mlockall() at the
> > > entry of the program? Wouldn't that greatly beneficial already with
> > > whatever granule of locks that a future fault would take?
> >
> > I don't care what your theory is, or even what your benchmarking shows.
> > I had basically the inverse of this patch, and my customer's workload
> > showed significant improvement as a result. Data talks, bullshit walks.
> > Your patch is NAKed and will remain NAKed.
>
> Either would you tell me your workload, I may try it.
>
> Or, please explain why it helps? If such huge library is in a single VMA,
> I don't see why per-vma lock is better than mmap lock. If the text is
> combined with multiple vmas, it should only help when each core faults at
> least on different vmas, not the same.
Oh, you really don't understand. The mmap_lock is catastrophically
overloaded. Before the per-VMA lock, every page fault took it for read,
and every call to mmap() took it for write. Because our rwsems are
fair, once one thread has called mmap() it waits for all existing page
faults to complete _and_ blocks all page faults from starting until
it has completed. That's a huge source of unexpected latency for any
multithreaded application.
Anything we can do to avoid taking the mmap_sem, even for read, helps any
multithreaded workload. Your suggestion that "this is rare, it doesn't
matter" shows that you don't get it. That you haven't found a workload
where you can measure it shows that your testing is inadequate.
Yes, there's added complexity with the per-VMA locks. But we need it for
good performance. Throwing away performance on a very small reduction
in complexity is a terrible trade-off.
next prev parent reply other threads:[~2024-04-11 14:51 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-10 17:06 Peter Xu
2024-04-10 20:26 ` Matthew Wilcox
[not found] ` <Zhb6B8UsidEEbFu3@x1n>
2024-04-10 21:10 ` Matthew Wilcox
2024-04-10 21:23 ` Peter Xu
2024-04-10 23:59 ` Matthew Wilcox
2024-04-11 0:20 ` Peter Xu
2024-04-11 14:50 ` Matthew Wilcox [this message]
2024-04-11 15:34 ` Peter Xu
2024-04-11 17:14 ` Matthew Wilcox
2024-04-11 15:42 ` Suren Baghdasaryan
2024-04-11 17:13 ` Liam R. Howlett
[not found] ` <ZhhSItiyLYBEdAX3@x1n>
2024-04-11 21:27 ` Matthew Wilcox
2024-04-11 21:46 ` Peter Xu
2024-04-11 22:02 ` Matthew Wilcox
2024-04-12 3:14 ` Matthew Wilcox
2024-04-12 12:38 ` Peter Xu
2024-04-12 13:06 ` Suren Baghdasaryan
2024-04-12 14:16 ` Matthew Wilcox
2024-04-12 14:53 ` Suren Baghdasaryan
2024-04-12 15:19 ` Matthew Wilcox
2024-04-12 15:31 ` Matthew Wilcox
2024-04-13 21:46 ` Suren Baghdasaryan
2024-04-13 22:52 ` Matthew Wilcox
2024-04-13 23:11 ` Suren Baghdasaryan
2024-04-13 21:41 ` Suren Baghdasaryan
2024-04-13 22:46 ` Matthew Wilcox
2024-04-15 15:58 ` Suren Baghdasaryan
2024-04-15 16:13 ` Matthew Wilcox
2024-04-15 16:19 ` Suren Baghdasaryan
2024-04-15 16:26 ` Matthew Wilcox
2024-04-12 12:46 ` Suren Baghdasaryan
2024-04-12 13:32 ` Matthew Wilcox
2024-04-12 13:46 ` Suren Baghdasaryan
2024-04-26 14:00 ` Matthew Wilcox
2024-04-26 15:07 ` Suren Baghdasaryan
2024-04-26 15:28 ` Matthew Wilcox
2024-04-26 15:32 ` Suren Baghdasaryan
2024-04-26 15:50 ` Matthew Wilcox
2024-04-26 15:32 ` Liam R. Howlett
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=Zhf4zqsfkz1XCwBN@casper.infradead.org \
--to=willy@infradead.org \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=lokeshgidra@google.com \
--cc=peterx@redhat.com \
--cc=surenb@google.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