vfio/virqfd: Drain events from eventfd in virqfd_wakeup()
authorDavid Woodhouse <dwmw@amazon.co.uk>
Tue, 27 Oct 2020 13:55:22 +0000 (13:55 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Sun, 15 Nov 2020 14:49:10 +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-3-dwmw2@infradead.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Acked-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/virqfd.c

index 997cb5d..414e98d 100644 (file)
@@ -46,6 +46,9 @@ static int virqfd_wakeup(wait_queue_entry_t *wait, unsigned mode, int sync, void
        __poll_t flags = key_to_poll(key);
 
        if (flags & EPOLLIN) {
+               u64 cnt;
+               eventfd_ctx_do_read(virqfd->eventfd, &cnt);
+
                /* An event has been signaled, call function */
                if ((!virqfd->handler ||
                     virqfd->handler(virqfd->opaque, virqfd->data)) &&