struct kvm_irqfd_pt *p = container_of(pt, struct kvm_irqfd_pt, pt);
        struct kvm_kernel_irqfd *irqfd = p->irqfd;
 
+       /*
+        * Add the irqfd as a priority waiter on the eventfd, with a custom
+        * wake-up handler, so that KVM *and only KVM* is notified whenever the
+        * underlying eventfd is signaled.
+        */
+       init_waitqueue_func_entry(&irqfd->wait, irqfd_wakeup);
+
        add_wait_queue_priority(wqh, &irqfd->wait);
 }
 
                mutex_unlock(&kvm->irqfds.resampler_lock);
        }
 
-       /*
-        * Install our own custom wake-up handling so we are notified via
-        * a callback whenever someone signals the underlying eventfd
-        */
-       init_waitqueue_func_entry(&irqfd->wait, irqfd_wakeup);
-
        /*
         * Set the irqfd routing and add it to KVM's list before registering
         * the irqfd with the eventfd, so that the routing information is valid