diff options
author | Davide Libenzi <davidel@xmailserver.org> | 2009-06-30 14:41:11 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-06-30 21:55:58 -0400 |
commit | 133890103b9de08904f909995973e4b5c08a780e (patch) | |
tree | 0cda85a58dafafa0a197cf1a789124203f1e7a88 /include/linux/eventfd.h | |
parent | f7c2df9b55212d5ec94169a4de11e44c683e0af4 (diff) |
eventfd: revised interface and cleanups
Change the eventfd interface to de-couple the eventfd memory context, from
the file pointer instance.
Without such change, there is no clean way to racely free handle the
POLLHUP event sent when the last instance of the file* goes away. Also,
now the internal eventfd APIs are using the eventfd context instead of the
file*.
This patch is required by KVM's IRQfd code, which is still under
development.
Signed-off-by: Davide Libenzi <davidel@xmailserver.org>
Cc: Gregory Haskins <ghaskins@novell.com>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: Benjamin LaHaise <bcrl@kvack.org>
Cc: Avi Kivity <avi@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/eventfd.h')
-rw-r--r-- | include/linux/eventfd.h | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/include/linux/eventfd.h b/include/linux/eventfd.h index f45a8ae5f828..3b85ba6479f4 100644 --- a/include/linux/eventfd.h +++ b/include/linux/eventfd.h | |||
@@ -8,10 +8,8 @@ | |||
8 | #ifndef _LINUX_EVENTFD_H | 8 | #ifndef _LINUX_EVENTFD_H |
9 | #define _LINUX_EVENTFD_H | 9 | #define _LINUX_EVENTFD_H |
10 | 10 | ||
11 | #ifdef CONFIG_EVENTFD | ||
12 | |||
13 | /* For O_CLOEXEC and O_NONBLOCK */ | ||
14 | #include <linux/fcntl.h> | 11 | #include <linux/fcntl.h> |
12 | #include <linux/file.h> | ||
15 | 13 | ||
16 | /* | 14 | /* |
17 | * CAREFUL: Check include/asm-generic/fcntl.h when defining | 15 | * CAREFUL: Check include/asm-generic/fcntl.h when defining |
@@ -27,16 +25,37 @@ | |||
27 | #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) | 25 | #define EFD_SHARED_FCNTL_FLAGS (O_CLOEXEC | O_NONBLOCK) |
28 | #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) | 26 | #define EFD_FLAGS_SET (EFD_SHARED_FCNTL_FLAGS | EFD_SEMAPHORE) |
29 | 27 | ||
28 | #ifdef CONFIG_EVENTFD | ||
29 | |||
30 | struct eventfd_ctx *eventfd_ctx_get(struct eventfd_ctx *ctx); | ||
31 | void eventfd_ctx_put(struct eventfd_ctx *ctx); | ||
30 | struct file *eventfd_fget(int fd); | 32 | struct file *eventfd_fget(int fd); |
31 | int eventfd_signal(struct file *file, int n); | 33 | struct eventfd_ctx *eventfd_ctx_fdget(int fd); |
34 | struct eventfd_ctx *eventfd_ctx_fileget(struct file *file); | ||
35 | int eventfd_signal(struct eventfd_ctx *ctx, int n); | ||
32 | 36 | ||
33 | #else /* CONFIG_EVENTFD */ | 37 | #else /* CONFIG_EVENTFD */ |
34 | 38 | ||
35 | #define eventfd_fget(fd) ERR_PTR(-ENOSYS) | 39 | /* |
36 | static inline int eventfd_signal(struct file *file, int n) | 40 | * Ugly ugly ugly error layer to support modules that uses eventfd but |
37 | { return 0; } | 41 | * pretend to work in !CONFIG_EVENTFD configurations. Namely, AIO. |
42 | */ | ||
43 | static inline struct eventfd_ctx *eventfd_ctx_fdget(int fd) | ||
44 | { | ||
45 | return ERR_PTR(-ENOSYS); | ||
46 | } | ||
47 | |||
48 | static inline int eventfd_signal(struct eventfd_ctx *ctx, int n) | ||
49 | { | ||
50 | return -ENOSYS; | ||
51 | } | ||
52 | |||
53 | static inline void eventfd_ctx_put(struct eventfd_ctx *ctx) | ||
54 | { | ||
55 | |||
56 | } | ||
38 | 57 | ||
39 | #endif /* CONFIG_EVENTFD */ | 58 | #endif |
40 | 59 | ||
41 | #endif /* _LINUX_EVENTFD_H */ | 60 | #endif /* _LINUX_EVENTFD_H */ |
42 | 61 | ||