summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2003-07-04 19:38:00 -0700
committerLinus Torvalds <torvalds@home.osdl.org>2003-07-04 19:38:00 -0700
commit0d98604b2849f0449b15bf0cb90654e949db4cb8 (patch)
tree5921666b7252af6f1ce44f1517e5f3b3249d0866 /include/linux
parent1c630a8df793686088620aa88913e3cb9b635353 (diff)
[PATCH] epoll: microoptimisations
From: Davide Libenzi <davidel@xmailserver.org> - Inline eventpoll_release() so that __fput() does not need to call in epoll code if the file itself is not registered inside an epoll fd - Add <linux/types.h> inclusion due __u32 and __u64 usage - Fix debug printf that would otherwise panic if enabled with the new epoll code
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/eventpoll.h35
1 files changed, 33 insertions, 2 deletions
diff --git a/include/linux/eventpoll.h b/include/linux/eventpoll.h
index 60f8cadb1f50..f89acbe8183a 100644
--- a/include/linux/eventpoll.h
+++ b/include/linux/eventpoll.h
@@ -14,6 +14,8 @@
#ifndef _LINUX_EVENTPOLL_H
#define _LINUX_EVENTPOLL_H
+#include <linux/types.h>
+
/* Valid opcodes to issue to sys_epoll_ctl() */
#define EPOLL_CTL_ADD 1
@@ -55,8 +57,37 @@ asmlinkage long sys_epoll_wait(int epfd, struct epoll_event *events, int maxeven
/* Used to initialize the epoll bits inside the "struct file" */
void eventpoll_init_file(struct file *file);
-/* Used in fs/file_table.c:__fput() to unlink files from the eventpoll interface */
-void eventpoll_release(struct file *file);
+/* Used to release the epoll bits inside the "struct file" */
+void eventpoll_release_file(struct file *file);
+
+/*
+ * This is called from inside fs/file_table.c:__fput() to unlink files
+ * from the eventpoll interface. We need to have this facility to cleanup
+ * correctly files that are closed without being removed from the eventpoll
+ * interface.
+ */
+static inline void eventpoll_release(struct file *file)
+{
+
+ /*
+ * Fast check to avoid the get/release of the semaphore. Since
+ * we're doing this outside the semaphore lock, it might return
+ * false negatives, but we don't care. It'll help in 99.99% of cases
+ * to avoid the semaphore lock. False positives simply cannot happen
+ * because the file in on the way to be removed and nobody ( but
+ * eventpoll ) has still a reference to this file.
+ */
+ if (likely(list_empty(&file->f_ep_links)))
+ return;
+
+ /*
+ * The file is being closed while it is still linked to an epoll
+ * descriptor. We need to handle this by correctly unlinking it
+ * from its containers.
+ */
+ eventpoll_release_file(file);
+}
+
#else