Re: [PATCH v10 17/19] KVM: xen: don't block on pfncache locks in kvm_xen_set_evtchn_fast()

From: David Woodhouse
Date: Thu Dec 14 2023 - 09:04:08 EST


On Mon, 2023-12-04 at 14:43 +0000, Paul Durrant wrote:
> From: Paul Durrant <pdurrant@xxxxxxxxxx>
>
> As described in [1] compiling with CONFIG_PROVE_RAW_LOCK_NESTING shows that
> kvm_xen_set_evtchn_fast() is blocking on pfncache locks in IRQ context.
> Instead, use read_trylock() and treat failure to lock the same as an
> invalid cache.
>
> [1] https://lore.kernel.org/lkml/99771ef3a4966a01fefd3adbb2ba9c3a75f97cf2.camel@xxxxxxxxxxxxx/T/#mbd06e5a04534ce9c0ee94bd8f1e8d942b2d45bd6
>
> Signed-off-by: Paul Durrant <pdurrant@xxxxxxxxxx>

Reviewed-by: David Woodhouse <dwmw@xxxxxxxxxxxx>

Although I would prefer the commit comment to note that this is only
wrong for PREEMPT_RT, as all those locks were irq-safe. This is because
PREEMPT_RT is going to turn them into mutexes — and mostly trick things
into working by making all IRQ handlers threaded... except this one
isn't just in an IRQ handler; its in an HRTIMER_MODE_ABS_HARD callback
which still *will* be in real interrupt context.

And there's no 'raw' version of the rwlock for us to use.

Attachment: smime.p7s
Description: S/MIME cryptographic signature