Re: 5.13-rt1 + KVM = WARNING: at fs/eventfd.c:74 eventfd_signal()

From: Paolo Bonzini
Date: Wed Jul 14 2021 - 06:44:47 EST


On 14/07/21 12:41, Michael S. Tsirkin wrote:
--------------- 8< ---------------
From: Paolo Bonzini <pbonzini@xxxxxxxxxx>
Subject: [PATCH] eventfd: protect eventfd_wake_count with a local_lock

eventfd_signal assumes that spin_lock_irqsave/spin_unlock_irqrestore is
non-preemptable and therefore increments and decrements the percpu
variable inside the critical section.

This obviously does not fly with PREEMPT_RT. If eventfd_signal is
preempted and an unrelated thread calls eventfd_signal, the result is
a spurious WARN. To avoid this, protect the percpu variable with a
local_lock.

Reported-by: Daniel Bristot de Oliveira <bristot@xxxxxxxxxx>
Fixes: b5e683d5cab8 ("eventfd: track eventfd_signal() recursion depth")
Cc: stable@xxxxxxxxxxxxxxx
Cc: He Zhe <zhe.he@xxxxxxxxxxxxx>
Cc: Jens Axboe <axboe@xxxxxxxxx>
Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>


Makes sense ...

Acked-by: Michael S. Tsirkin <mst@xxxxxxxxxx>

want to send this to the windriver guys so they can test?
Here's the list from that thread:

I included He Zhe, but it should be enough for Daniel to test it. The bug is quite obvious once you wear your PREEMPT_RT goggles.

Paolo