From: Davide Libenzi <[email protected]>

And give them a change to unregister from the wait queue.

This is turn allows eventfd users to use the eventfd file* w/out holding a
live reference to it.

After the eventfd user callbacks returns, any usage of the eventfd file*
should be dropped.  The eventfd user callback can acquire sleepy locks
since it is invoked lockless.

This is a feature, needed by KVM to avoid an awkward workaround when using
eventfd.

Signed-off-by: Davide Libenzi <[email protected]>
Tested-by: Gregory Haskins <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Gregory Haskins <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>

diff --git a/fs/eventfd.c b/fs/eventfd.c
index 3f0e197..72f5f8d 100644
--- a/fs/eventfd.c
+++ b/fs/eventfd.c
@@ -61,7 +61,15 @@ EXPORT_SYMBOL_GPL(eventfd_signal);
 
 static int eventfd_release(struct inode *inode, struct file *file)
 {
-       kfree(file->private_data);
+       struct eventfd_ctx *ctx = file->private_data;
+
+       /*
+        * No need to hold the lock here, since we are on the file cleanup
+        * path and the ones still attached to the wait queue will be
+        * serialized by wake_up_locked_poll().
+        */
+       wake_up_locked_poll(&ctx->wqh, POLLHUP);
+       kfree(ctx);
        return 0;
 }
 
--
To unsubscribe from this list: send the line "unsubscribe kvm-commits" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to