Re: [PATCH v2 01/20] locking/rt: Use raw_spin_lock_irqsave() in __rwbase_read_unlock()

From: Paolo Bonzini

Date: Sat May 30 2026 - 10:41:44 EST


On Sat, May 30, 2026 at 3:04 PM David Woodhouse <dwmw2@xxxxxxxxxxxxx> wrote:
>
> On Sat, 2026-05-30 at 12:26 +0200, Paolo Bonzini wrote:
> >
> > Yeah, I think so.
> >
> > The write side needs kvm->srcu so it would have to be yet another SRCU.
> > I initially thought that sucks for the code that calls kvm_gpc_check(),
> > but maybe not because it simply replaces read_lock/read_unlock.
> >
> > By using a seqcount for the data, SRCU only needs to be synchronized in
> > gpc_unmap(). So, something like this:
>
> It isn't just gpc_unmap() which does the invalidation. We also
> invalidate from the MMU notifier in gfn_to_pfn_cache_invalidate_start()
> which would also have to synchronize, wouldn't it?

You're right, the write_lock_irq() there drains the readers and that
is needed because khva is not pinned, only kmap()-ed.

That is already broken for the OOM case under PREEMPT_RT, where
rwlock_t becomes sleepable. But using SRCU would break it on
!PREEMPT_RT as well.

Paolo