eventfd - allow atomic read and waitqueue remove
KVM needs a wait to atomically remove themselves from the eventfd ->poll() wait queue head, in order to handle correctly their IRQfd deassign operation. This patch introduces such API, plus a way to read an eventfd from its context. Signed-off-by: Davide Libenzi <davidel@xmailserver.org> Signed-off-by: Avi Kivity <avi@redhat.com>
This commit is contained in:

committed by
Marcelo Tosatti

parent
a6085fbaf6
commit
cb289d6244
@@ -10,6 +10,7 @@
|
||||
|
||||
#include <linux/fcntl.h>
|
||||
#include <linux/file.h>
|
||||
#include <linux/wait.h>
|
||||
|
||||
/*
|
||||
* CAREFUL: Check include/asm-generic/fcntl.h when defining
|
||||
@@ -34,6 +35,9 @@ struct file *eventfd_fget(int fd);
|
||||
struct eventfd_ctx *eventfd_ctx_fdget(int fd);
|
||||
struct eventfd_ctx *eventfd_ctx_fileget(struct file *file);
|
||||
int eventfd_signal(struct eventfd_ctx *ctx, int n);
|
||||
ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait, __u64 *cnt);
|
||||
int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx, wait_queue_t *wait,
|
||||
__u64 *cnt);
|
||||
|
||||
#else /* CONFIG_EVENTFD */
|
||||
|
||||
@@ -61,6 +65,18 @@ static inline void eventfd_ctx_put(struct eventfd_ctx *ctx)
|
||||
|
||||
}
|
||||
|
||||
static inline ssize_t eventfd_ctx_read(struct eventfd_ctx *ctx, int no_wait,
|
||||
__u64 *cnt)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static inline int eventfd_ctx_remove_wait_queue(struct eventfd_ctx *ctx,
|
||||
wait_queue_t *wait, __u64 *cnt)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _LINUX_EVENTFD_H */
|
||||
|
Reference in New Issue
Block a user