[lkml]   [2009]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
Patch in this message
Subject[KVM PATCH v2 1/2] Allow waiters to be notified about the eventfd file* going away, and give
From: Davide Libenzi <>

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

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

[gmh: pulled from -mmotm for inclusion in kvm.git]

Signed-off-by: Davide Libenzi <>
Tested-by: Gregory Haskins <>
Signed-off-by: Andrew Morton <>
Signed-off-by: Gregory Haskins <>

fs/eventfd.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)

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;

 \ /
  Last update: 2009-06-04 14:51    [W:0.109 / U:1.644 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site