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

David Woodhouse
2023-12-14T14:04:08Z

[-- Attachment #1: Type: text/plain, Size: 1075 bytes --]

On Mon, 2023-12-04 at 14:43 +0000, Paul Durrant wrote:
> From: Paul Durrant <pdurrant@amazon.com>
>
> 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@infradead.org/T/#mbd06e5a04534ce9c0ee94bd8f1e8d942b2d45bd6
>
> Signed-off-by: Paul Durrant <pdurrant@amazon.com>

Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>

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 #2: smime.p7s --]
[-- Type: application/pkcs7-signature, Size: 5965 bytes --]