The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Sean Christopherson <seanjc@google.com>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Jason Gunthorpe <jgg@ziepe.ca>, Michal Hocko <mhocko@suse.com>,
	 Steven Rostedt <rostedt@goodmis.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	 David Hildenbrand <david@kernel.org>,
	Lorenzo Stoakes <ljs@kernel.org>,
	 "Liam R. Howlett" <liam@infradead.org>,
	Vlastimil Babka <vbabka@kernel.org>,
	Mike Rapoport <rppt@kernel.org>,
	 Suren Baghdasaryan <surenb@google.com>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	 Clark Williams <clrkwllms@kernel.org>,
	Simona Vetter <simona.vetter@ffwll.ch>,
	 Jerome Glisse <jglisse@redhat.com>,
	Christian Koenig <christian.koenig@amd.com>,
	 Paolo Bonzini <pbonzini@redhat.com>,
	linux-mm@kvack.org, kvm@vger.kernel.org,
	 linux-rt-devel@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mm/mmu_notifier: Remove non_block_start/end() from notifier invocation
Date: Tue, 25 Aug 2026 12:58:37 -0700	[thread overview]
Message-ID: <ao3z7Rtw2FROkVpy@google.com> (raw)
In-Reply-To: <b0be19e9-b0ae-48de-bef6-d905ee007c8a@paulmck-laptop>

On Tue, Aug 25, 2026, Paul E. McKenney wrote:
> On Tue, Aug 25, 2026 at 06:48:08PM +0100, David Woodhouse wrote:
> > On Tue, 2026-08-25 at 10:19 -0700, Paul E. McKenney wrote:
> > > On Tue, Aug 25, 2026 at 06:05:54PM +0100, David Woodhouse wrote:
> > > > On Tue, 2026-08-25 at 09:47 -0700, Paul E. McKenney wrote:
> > > > > 
> > > > > On the tail latencies...
> > > > > 
> > > > > The easiest way to reduce them is to require that preemption be disabled
> > > > > across srcu_read_lock_atomic()/srcu_read_unlock_atomic() regions and
> > > > > across all calls to synchronize_srcu_atomic().  Without that, the problem
> > > > > is that the scheduler does not know that the spinning is pointless,
> > > > > and we cannot use the blocking primitives that we could otherwise use
> > > > > to tell it what is going on.
> > > > > 
> > > > > So, is it feasible to simply require preemption be disabled as called
> > > > > out above?
> > > > 
> > > > I'd experimented with disabling it around the GP driver loop in
> > > > synchronize_srcu_atomic() as seen in
> > > > https://git.infradead.org/?p=users/dwmw2/linux.git;a=commitdiff;h=07165e79340e
> > > > and that didn't seem to change anything (which seems reasonable, as
> > > > it's the *waiters* that were descheduled, not the threads driving the
> > > > actual GP). So your suggestion that we do it around the whole function
> > > > certainly makes sense too. I'll test it.
> > > > 
> > > > I do wonder if we're really doing the right thing here by selfishly
> > > > blocking preemption because we want a specific tail latency to remain
> > > > low in a contended system. Maybe we should allow preemption and trust
> > > > that the right thing will happen?

In my experience, preempting MMU operations, especially mmu_notifier invalidations,
is rarely a good idea.  E.g. see commit d02c357e5bfa ("KVM: x86/mmu: Retry fault
before acquiring mmu_lock if mapping is changing"), which worked around an issue
where KVM would drop mmu_lock and yield in an mmu_notifier callback on preemptible
kernels.  We "fixed" the issue by avoiding mmu_lock contention, because it was the
easiest fix and benefited all setups, but the underlying problem that made us take
action was very specifically yielding mmu_lock on preemptible kernels.

This isn't exactly the same, but it sounds quite similar: being greedy and hogging
the CPU to complete an operation can actually be beneficial for overall throughput,
not just for the immediate operation's latency, by avoiding trash and overhead that
is incurred as a result of yielding or being preempted.

> > > > Maybe the p100 isn't the right benchmark to be chasing... I'm looking
> > > > at it because Sean expressed concerns about it, but it's not the only
> > > > consideration.
> > > 
> > > My concern is algorithmic, not benchmark optimization.
> > > 
> > > Suppose that there is only one CPU, or, alternatively, that one of the
> > > atomic SRCU readers is pinned to the same CPU occupied by the (higher
> > > priority) task running synchronize_srcu_atomic().  In this case, the
> > > call to synchronize_srcu_atomic() uselessly burns CPU time until its
> > > priority decays, real-time throttling kicks in, or in some configurations,
> > > maybe never.
> > 
> > I certainly have no problem with a blanket preempt_disable() around
> > both sides for algorithmic reasons. As long as we aren't *just* doing
> > it for the selfish reasons I described. 
> 
> Suppose I simply disable preemption in srcu_read_lock_atomic(),
> enable it in srcu_read_unlock_atomic(), and disable it internally to
> synchronize_srcu_atomic()?  It might be against all RCU tradition,
> but might also be easier to use.  ;-)
> 
> > > Requiring preemption be disabled across both the atomic SRCU readers
> > > and the synchronize_srcu_atomic() avoids this, at least when running on
> > > bare metal.  My (perhaps naive) hope is that guest OSes get some use
> > > out of those cpu_relax() calls.
> > 
> > Yeah, an overcommited guest vCPU should be able to get preempted there
> > by the hypervisor, allowing other vCPUs to run.
> 
> Whew!!!  ;-)

Ya, and on KVM x86 at least, cpu_relax() => PAUSE will conditionally trigger a
VM-Exit after enough spins that causes KVM-the-host to try to yield the vCPU to
another vCPU in the same VM.  The intended use case is to detect when a vCPU is
spinning waiting for a lock, to try and give cycles to the vCPU that is holding
said lock.  IIUC, the same principle should apply here.

  reply	other threads:[~2026-08-25 19:58 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11  8:58 [PATCH] mm/mmu_notifier: Remove non_block_start/end() from notifier invocation David Woodhouse
2026-08-11 13:55 ` Jason Gunthorpe
2026-08-11 14:21   ` David Woodhouse
2026-08-11 14:27     ` Jason Gunthorpe
2026-08-11 14:33       ` David Woodhouse
2026-08-11 14:42         ` Steven Rostedt
2026-08-11 15:24           ` David Woodhouse
2026-08-11 15:30             ` Jason Gunthorpe
2026-08-12  8:14             ` Michal Hocko
2026-08-12  8:21               ` David Woodhouse
2026-08-12 12:27                 ` Jason Gunthorpe
2026-08-12 13:46                   ` David Woodhouse
2026-08-12 13:49                     ` Jason Gunthorpe
2026-08-12 14:05                       ` David Woodhouse
2026-08-12 14:26                         ` Jason Gunthorpe
2026-08-12 14:38                           ` David Woodhouse
2026-08-13 10:05                             ` David Woodhouse
2026-08-13 13:59                               ` Sean Christopherson
2026-08-13 14:40                                 ` Jason Gunthorpe
2026-08-12 14:34                         ` David Woodhouse
2026-08-12 15:03                           ` David Woodhouse
2026-08-12 15:49                             ` David Woodhouse
2026-08-12 16:20                               ` Sean Christopherson
2026-08-12 17:17                                 ` David Woodhouse
2026-08-12 21:38                                   ` Paul E. McKenney
2026-08-13  7:54                                     ` David Woodhouse
2026-08-18 18:18                                       ` Paul E. McKenney
2026-08-18 18:28                                         ` David Woodhouse
2026-08-20 14:43                                         ` David Woodhouse
2026-08-21 17:38                                           ` Paul E. McKenney
2026-08-25 12:15                                             ` David Woodhouse
2026-08-25 16:47                                               ` Paul E. McKenney
2026-08-25 17:05                                                 ` David Woodhouse
2026-08-25 17:19                                                   ` Paul E. McKenney
2026-08-25 17:48                                                     ` David Woodhouse
2026-08-25 18:16                                                       ` Paul E. McKenney
2026-08-25 19:58                                                         ` Sean Christopherson [this message]
2026-08-25 20:51                                                           ` Paul E. McKenney
2026-08-26  7:32                                                             ` Sebastian Andrzej Siewior
2026-08-26  7:38                                                               ` David Woodhouse
2026-08-12 16:04                             ` Paolo Bonzini
2026-08-12 16:07                               ` Jason Gunthorpe
2026-08-12 17:49                               ` David Woodhouse
2026-08-20 13:30                                 ` Sebastian Andrzej Siewior
2026-08-20 14:26                                   ` David Woodhouse
2026-08-20 15:34                                     ` Sebastian Andrzej Siewior
2026-08-20 18:49                                       ` David Woodhouse
2026-08-12  8:13           ` Michal Hocko
2026-08-11 15:29         ` Jason Gunthorpe
2026-08-11 15:15       ` David Woodhouse
2026-08-11 15:24         ` Jason Gunthorpe
2026-08-11 15:29           ` David Woodhouse
2026-08-11 16:24             ` Jason Gunthorpe
2026-08-11 17:22               ` David Woodhouse
2026-08-11 17:26                 ` Jason Gunthorpe
2026-08-11 17:59                   ` David Woodhouse
2026-08-11 18:19                     ` Jason Gunthorpe
2026-08-11 20:06                       ` Sean Christopherson
2026-08-11 20:21                         ` Paolo Bonzini
2026-08-11 21:14                           ` David Woodhouse
2026-08-11 22:58                             ` Sean Christopherson
2026-08-11 23:50                               ` David Woodhouse
2026-08-12 10:25                                 ` David Woodhouse
2026-08-12 16:07                                 ` Sean Christopherson
2026-08-11 20:29                         ` David Woodhouse
2026-08-11 15:12 ` David Hildenbrand (Arm)

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=ao3z7Rtw2FROkVpy@google.com \
    --to=seanjc@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=bigeasy@linutronix.de \
    --cc=christian.koenig@amd.com \
    --cc=clrkwllms@kernel.org \
    --cc=david@kernel.org \
    --cc=dwmw2@infradead.org \
    --cc=jgg@ziepe.ca \
    --cc=jglisse@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=liam@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-rt-devel@lists.linux.dev \
    --cc=ljs@kernel.org \
    --cc=mhocko@suse.com \
    --cc=paulmck@kernel.org \
    --cc=pbonzini@redhat.com \
    --cc=rostedt@goodmis.org \
    --cc=rppt@kernel.org \
    --cc=simona.vetter@ffwll.ch \
    --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