kvm/eventfd: Drain events from eventfd in irqfd_wakeup()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 27 Oct 2020 13:55:23 +0000 (13:55 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 15 Nov 2020 14:49:11 +0000 (09:49 -0500)
Don't allow the events to accumulate in the eventfd counter, drain them
as they are handled.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Message-Id: <20201027135523.646811-4-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
virt/kvm/eventfd.c

index efa8a5a..e996989 100644 (file)
@@ -194,6 +194,9 @@ irqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void *key)
        int ret = 0;
 
        if (flags & EPOLLIN) {
+               u64 cnt;
+               eventfd_ctx_do_read(irqfd->eventfd, &cnt);
+
                idx = srcu_read_lock(&kvm->irq_srcu);
                do {
                        seq = read_seqcount_begin(&irqfd->irq_entry_sc);