Skip to contentSkip to conversation

/dev/epoll port to 2.5.42

PATCH New Hanna Linder 1 participant 1 message Oct 15, 2002

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 /dev/epoll port to 2.5.42

More fuel for the fire.

Here is a port of Davide Libenzi's /dev/epoll patch from 2.5.33 to 2.5.42. A solution of some sort would be nice to see in 2.6, please consider either /dev/epoll or asynch poll again.

Here is the link to Davide's performance results with /dev/epoll
http://www.xmailserver.org/linux-patches/nio-improve.html

(Putting on my asbestos overalls)

Hanna

-----

Makefile +1 -1
diff -Nru -X dontdiff linux-2.5.42/Makefile linux-2.5.42-epoll/Makefile
@@ -1,7 +1,7 @@
 VERSION = 2
 PATCHLEVEL = 5
 SUBLEVEL = 42
-EXTRAVERSION =
+EXTRAVERSION = epoll
 
 # *DOCUMENTATION*
 # To see a list of typical targets execute "make help"
drivers/char/Config.help +19 -0
diff -Nru -X dontdiff linux-2.5.42/drivers/char/Config.help linux-2.5.42-epoll/drivers/char/Config.help
@@ -929,6 +929,25 @@
   The module will be called nvram.o. If you want to compile it as a
   module, say M here and read <file:Documentation/modules.txt>.
 
+CONFIG_EVENTPOLL
+  This option will allow for the creation of a '/dev/epoll' character
+  device, with major number 10 (MISC_MAJOR) and minor number 124
+  (EVENTPOLL_MINOR).
+
+  This device can be used to very efficiently handle incoming events 
+  on a socket, much more so than select() or poll(). There is a paper 
+  that describes this device and how to program for it (as well as 
+  including some very impressive benchmarks) at the following URL:
+  http://www.xmailserver.org/linux-patches/nio-improve.html
+
+  If you are writing very scalable servers and wish to code against
+  /dev/epoll for enhanced speed, say 'Y' or 'M' here. If you have
+  software in hand that requires (or can make use of) /dev/epoll,
+  also say 'Y' or 'M' here.
+
+  The vast majority of the planet can very safely say 'N' here
+  and breathe easily.
+
 CONFIG_NWBUTTON
   If you say Y here and create a character device node /dev/nwbutton
   with major and minor numbers 10 and 158 ("man mknod"), then every
drivers/char/Config.in +1 -0
diff -Nru -X dontdiff linux-2.5.42/drivers/char/Config.in linux-2.5.42-epoll/drivers/char/Config.in
@@ -154,6 +154,7 @@
    dep_tristate 'AMD 768 Random Number Generator support' CONFIG_AMD_RNG $CONFIG_PCI
 fi
 tristate '/dev/nvram support' CONFIG_NVRAM
+tristate '/dev/epoll - Efficent file event polling method' CONFIG_EVENTPOLL
 tristate 'Enhanced Real Time Clock Support' CONFIG_RTC
 if [ "$CONFIG_RTC" != "y" ]; then
    tristate 'Generic /dev/rtc emulation' CONFIG_GEN_RTC      
drivers/char/Makefile +1 -0
diff -Nru -X dontdiff linux-2.5.42/drivers/char/Makefile linux-2.5.42-epoll/drivers/char/Makefile
@@ -63,6 +63,7 @@
 ifeq ($(CONFIG_PPC),)
   obj-$(CONFIG_NVRAM) += nvram.o
 endif
+obj-$(CONFIG_EVENTPOLL) += eventpoll.o
 obj-$(CONFIG_TOSHIBA) += toshiba.o
 obj-$(CONFIG_I8K) += i8k.o
 obj-$(CONFIG_DS1620) += ds1620.o
drivers/char/eventpoll.c +800 -0

800 lines not on this page · raw message

fs/Makefile +2 -2
diff -Nru -X dontdiff linux-2.5.42/fs/Makefile linux-2.5.42-epoll/fs/Makefile
@@ -6,14 +6,14 @@
 # 
 
 export-objs :=	open.o dcache.o buffer.o bio.o inode.o dquot.o mpage.o aio.o \
-                fcntl.o read_write.o
+                fcntl.o read_write.o fcblist.o
 
 obj-y :=	open.o read_write.o devices.o file_table.o buffer.o \
 		bio.o super.o block_dev.o char_dev.o stat.o exec.o pipe.o \
 		namei.o fcntl.o ioctl.o readdir.o select.o fifo.o locks.o \
 		dcache.o inode.o attr.o bad_inode.o file.o iobuf.o dnotify.o \
 		filesystems.o namespace.o seq_file.o xattr.o libfs.o \
-		fs-writeback.o mpage.o direct-io.o aio.o
+		fs-writeback.o mpage.o direct-io.o aio.o fcblist.o
 
 ifneq ($(CONFIG_NFSD),n)
 ifneq ($(CONFIG_NFSD),)
fs/fcblist.c +130 -0

130 lines not on this page · raw message

fs/file_table.c +4 -0
diff -Nru -X dontdiff linux-2.5.42/fs/file_table.c linux-2.5.42-epoll/fs/file_table.c
@@ -8,6 +8,7 @@
 #include <linux/string.h>
 #include <linux/slab.h>
 #include <linux/file.h>
+#include <linux/fcblist.h>
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/smp_lock.h>
@@ -59,6 +60,7 @@
 		f->f_gid = current->fsgid;
 		f->f_owner.lock = RW_LOCK_UNLOCKED;
 		list_add(&f->f_list, &anon_list);
+		file_notify_init(f);
 		file_list_unlock();
 		return f;
 	}
@@ -103,6 +105,7 @@
 	filp->f_uid    = current->fsuid;
 	filp->f_gid    = current->fsgid;
 	filp->f_op     = dentry->d_inode->i_fop;
+	file_notify_init(filp);
 	if (filp->f_op->open)
 		return filp->f_op->open(dentry->d_inode, filp);
 	else
@@ -124,6 +127,7 @@
 	struct vfsmount * mnt = file->f_vfsmnt;
 	struct inode * inode = dentry->d_inode;
 
+	file_notify_cleanup(file);
 	locks_remove_flock(file);
 
 	if (file->f_op && file->f_op->release)
fs/pipe.c +38 -4

117 lines not on this page · raw message

include/asm-i386/poll.h +1 -0
diff -Nru -X dontdiff linux-2.5.42/include/asm-i386/poll.h linux-2.5.42-epoll/include/asm-i386/poll.h
@@ -15,6 +15,7 @@
 #define POLLWRNORM	0x0100
 #define POLLWRBAND	0x0200
 #define POLLMSG		0x0400
+#define POLLREMOVE	0x1000
 
 struct pollfd {
 	int fd;
include/linux/eventpoll.h +43 -0

43 lines not on this page · raw message

include/linux/fcblist.h +68 -0

68 lines not on this page · raw message

include/linux/fs.h +4 -0
diff -Nru -X dontdiff linux-2.5.42/include/linux/fs.h linux-2.5.42-epoll/include/linux/fs.h
@@ -505,6 +505,10 @@
 
 	/* needed for tty driver, and maybe others */
 	void			*private_data;
+
+	/* file callback list */
+	rwlock_t f_cblock;
+	struct list_head f_cblist;
 };
 extern spinlock_t files_lock;
 #define file_list_lock() spin_lock(&files_lock);
include/linux/list.h +5 -0
diff -Nru -X dontdiff linux-2.5.42/include/linux/list.h linux-2.5.42-epoll/include/linux/list.h
@@ -240,6 +240,11 @@
 	     pos = list_entry(pos->member.next, typeof(*pos), member),	\
 		     prefetch(pos->member.next))
 
+#define list_first(head)	(((head)->next != (head)) ? (head)->next: (struct list_head *) 0)
+#define list_last(head)	(((head)->prev != (head)) ? (head)->prev: (struct list_head *) 0)
+#define list_next(pos, head)	(((pos)->next != (head)) ? (pos)->next: (struct list_head *) 0)
+#define list_prev(pos, head)	(((pos)->prev != (head)) ? (pos)->prev: (struct list_head *) 0)
+
 #endif /* __KERNEL__ || _LVM_H_INCLUDE */
 
 #endif
include/linux/pipe_fs_i.h +4 -0
diff -Nru -X dontdiff linux-2.5.42/include/linux/pipe_fs_i.h linux-2.5.42-epoll/include/linux/pipe_fs_i.h
@@ -12,6 +12,8 @@
 	unsigned int waiting_writers;
 	unsigned int r_counter;
 	unsigned int w_counter;
+	struct file *rdfile;
+	struct file *wrfile;
 	struct fasync_struct *fasync_readers;
 	struct fasync_struct *fasync_writers;
 };
@@ -30,6 +32,8 @@
 #define PIPE_WAITING_WRITERS(inode)	((inode).i_pipe->waiting_writers)
 #define PIPE_RCOUNTER(inode)	((inode).i_pipe->r_counter)
 #define PIPE_WCOUNTER(inode)	((inode).i_pipe->w_counter)
+#define PIPE_READFILE(inode)	((inode).i_pipe->rdfile)
+#define PIPE_WRITEFILE(inode)	((inode).i_pipe->wrfile)
 #define PIPE_FASYNC_READERS(inode)     (&((inode).i_pipe->fasync_readers))
 #define PIPE_FASYNC_WRITERS(inode)     (&((inode).i_pipe->fasync_writers))
 
include/net/sock.h +9 -1
diff -Nru -X dontdiff linux-2.5.42/include/net/sock.h linux-2.5.42-epoll/include/net/sock.h
@@ -51,6 +51,9 @@
 
 #include <asm/atomic.h>
 #include <net/dst.h>
+#include <linux/fs.h>
+#include <linux/file.h>
+#include <linux/fcblist.h>
 
 /*
  * This structure really needs to be cleaned up.
@@ -744,8 +747,13 @@
 
 static inline void sk_wake_async(struct sock *sk, int how, int band)
 {
-	if (sk->socket && sk->socket->fasync_list)
+	if (sk->socket) {
+		if (sk->socket->file)
+			file_send_notify(sk->socket->file, ion_band_table[band - POLL_IN],
+					poll_band_table[band - POLL_IN]);
+		if (sk->socket->fasync_list)
 		sock_wake_async(sk->socket, how, band);
+	}
 }
 
 #define SOCK_MIN_SNDBUF 2048
net/ipv4/tcp.c +2 -2
diff -Nru -X dontdiff linux-2.5.42/net/ipv4/tcp.c linux-2.5.42-epoll/net/ipv4/tcp.c
@@ -474,8 +474,8 @@
 		if (sk->sleep && waitqueue_active(sk->sleep))
 			wake_up_interruptible(sk->sleep);
 
-		if (sock->fasync_list && !(sk->shutdown & SEND_SHUTDOWN))
-			sock_wake_async(sock, 2, POLL_OUT);
+		if (!(sk->shutdown & SEND_SHUTDOWN))
+			sk_wake_async(sk, 2, POLL_OUT);
 	}
 }