mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pedro Falcato <pfalcato@suse.de>
To: "Lorenzo Stoakes (ARM)" <ljs@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	 Suren Baghdasaryan <surenb@google.com>,
	"Liam R. Howlett" <liam@infradead.org>,
	 Vlastimil Babka <vbabka@kernel.org>,
	Shakeel Butt <shakeel.butt@linux.dev>,
	 David Hildenbrand <david@kernel.org>,
	Mike Rapoport <rppt@kernel.org>, Michal Hocko <mhocko@suse.com>,
	 Jonathan Corbet <corbet@lwn.net>,
	Randy Dunlap <rdunlap@infradead.org>,
	 Jann Horn <jannh@google.com>,
	linux-mm@kvack.org, linux-doc@vger.kernel.org,
	 linux-kernel@vger.kernel.org,
	"Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
	 Daehyeon Ko <4ncienth@gmail.com>
Subject: Re: [PATCH v2] mm/vma: avoid spurious write locks when mm->mm_lock_seq overflows
Date: Wed, 28 Oct 2026 15:06:27 +0000	[thread overview]
Message-ID: <auIPRjj2t0BcYlOa@pedro-suse.tail5790ac.ts.net> (raw)
In-Reply-To: <auIIxSorX0bhZNZc@gremlin>

On Wed, Oct 28, 2026 at 03:04:07PM +0000, Lorenzo Stoakes (ARM) wrote:
> On Mon, Oct 19, 2026 at 01:19:45PM +0100, Lorenzo Stoakes (ARM) wrote:
> > On Mon, Oct 19, 2026 at 10:53:27AM +0100, Pedro Falcato wrote:
> > > On Fri, Oct 16, 2026 at 12:34:33PM +0100, Lorenzo Stoakes (ARM) wrote:
> > > I'm concerned by the possible latency when doing this to many VMAs. Do you
> > > have any numbers?
> >
> > No, somebody schloppened a patch for a real issue and I haven't the time to do
> > even the things I need to do let alone 'here's a new task' stuff :)
> >
> > However, this is a simple write to every VMA, done at the point the mmap write
> > lock is held with all VMA write locks dropped.
> >
> > It was implemented such that:
> >
> > * No VMA write lock is taken on the VMAs.
> > * VMA read locks can proceed.
> >
> > I.e. it amounts to a loop over VMAs and a write to a field.
> >
> > I don't think you could possibly do more to reduce latency here, and you
> > absolutely have to update this field across the board.
> >
> > Under any realistic workloads this will occur at worst ~days intervals, often
> > far longer, and likely you will see quite some gaps between separate processes
> > experiencing it.
> >
> > There's also an upper bound of vm.max_map_count per-process, so it can't explode
> > into something truly insane.
> >
> > Most processes don't have that many VMAs, other than certain steam games :) so
> > it's hard to imagine there really would be that much latency here.
> >
> > And the latency is occurring on one thread, which is performing an mmap unlock,
> > so nobody sane will put that on a hot path.
> 
> Sorry, I forgot about this and didn't get numbers to back this.
> 
> I had an LLM go get numbers on this, all in ms on my threadripper (but numbers
> should scale similarly) with fork() + munmap() all VMAs for comparison:
> 
> (all ms)
> 
>       VMAs      reset    reset     fork()     munmap()
>                 (warm)   (cold)    (cold)     all VMAs
>   --------    -------  -------    -------    ---------
>      1,000      0.006    0.041       0.33         0.43
>     10,000      0.072    0.36        2.1          4.2
>     65,500      0.61     2.4        14.1         33.5	(default)
>    262,144      5.3      9.6        60          168
>  1,048,000     34.7     39.2       237          691
>  4,194,304    162      163         954         2810
> 
> It happens on a random VMA write lock release, so there could be tail
> latency, but it'd be tail latency on the scale of ~weeks for normal
> workloads, and (assuming max map count reached at default limit) a ~2ms
> latency for an operation such as mprotect(), madvise(), mmap() or munmap()
> which shouldn't be placed in any situation where the latency of that call
> matters.
> 
> One call in 2^31 is the
> 99.99999995th percentile, far beyond any latency target anyone measures.
> 
> The amortised time per write-lock cycle is ~18 picoseconds (0.018 ns).

Thanks, this addresses my concerns :)

> 
> Interestingly, the runner observed khugepaged-induced mmap lock stalls of
> ~100ms, far far more regularly, which seriously exceeds any of these
> numbers, about which I assume we haven't had too much complaint.

Wow, that's horrible.

-- 
Pedro

  reply	other threads:[~2026-10-28 15:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16 11:34 Lorenzo Stoakes (ARM)
2026-10-16 12:16 ` Jose A. Perez de Azpillaga
2026-10-16 14:55 ` Lorenzo Stoakes (ARM)
2026-10-17  3:12 ` Andrew Morton
2026-10-19  9:53 ` Pedro Falcato
2026-10-19 12:19   ` Lorenzo Stoakes (ARM)
2026-10-19 14:32     ` Andrew Morton
2026-10-19 14:39       ` Lorenzo Stoakes (ARM)
2026-10-19 14:40         ` Lorenzo Stoakes (ARM)
2026-10-28 15:04     ` Lorenzo Stoakes (ARM)
2026-10-28 15:06       ` Pedro Falcato [this message]
2026-10-29  0:34         ` Suren Baghdasaryan

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=auIPRjj2t0BcYlOa@pedro-suse.tail5790ac.ts.net \
    --to=pfalcato@suse.de \
    --cc=4ncienth@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=azpijr@gmail.com \
    --cc=corbet@lwn.net \
    --cc=david@kernel.org \
    --cc=jannh@google.com \
    --cc=liam@infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=rdunlap@infradead.org \
    --cc=rppt@kernel.org \
    --cc=shakeel.butt@linux.dev \
    --cc=surenb@google.com \
    --cc=vbabka@kernel.org \
    /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®