[PATCH] f_op->poll() without lock_kernel()

From: Manfred Spraul (manfreds@colorfullife.com)
Date: Fri Apr 21 2000 - 13:03:42 EST


kumon@flab.fujitsu.co.jp noticed that select() caused a high contention
for the kernel lock, so here is a patch that removes lock_kernel() from
poll().

I tested that patch with 2.3.99-pre5.

--
	Manfred

// $Header$ // Kernel Version: // VERSION = 2 // PATCHLEVEL = 3 // SUBLEVEL = 99 // EXTRAVERSION = -pre5 --- 2.3/net/socket.c Wed Apr 12 15:00:35 2000 +++ build-2.3/net/socket.c Fri Apr 21 19:27:24 2000 @@ -566,7 +566,6 @@ struct socket *sock; int err; - unlock_kernel(); sock = socki_lookup(file->f_dentry->d_inode); /* @@ -574,7 +573,6 @@ */ err = sock->ops->poll(file, sock, wait); - lock_kernel(); return err; } --- 2.3/fs/select.c Thu Feb 10 22:39:09 2000 +++ build-2.3/fs/select.c Fri Apr 21 19:27:48 2000 @@ -194,7 +194,6 @@ retval = 0; for (;;) { set_current_state(TASK_INTERRUPTIBLE); - lock_kernel(); for (i = 0 ; i < n; i++) { unsigned long bit = BIT(i); unsigned long mask; @@ -227,7 +226,6 @@ wait = NULL; } } - unlock_kernel(); wait = NULL; if (retval || !__timeout || signal_pending(current)) break; @@ -462,9 +460,7 @@ goto out_fds1; } - lock_kernel(); fdcount = do_poll(nfds, nchunks, nleft, fds, wait, timeout); - unlock_kernel(); /* OK, now copy the revents fields back to user space. */ for(i=0; i < nchunks; i++) --- 2.3/include/linux/fs.h Wed Apr 12 15:00:31 2000 +++ build-2.3/include/linux/fs.h Fri Apr 21 19:40:12 2000 @@ -689,6 +689,12 @@ int (*revalidate) (kdev_t); }; +/* + * NOTE: + * read, write, poll, fsync, readv, writev can be called + * without the big kernel lock held in all filesystems. + * fasync can be called at interrupt time. + */ struct file_operations { loff_t (*llseek) (struct file *, loff_t, int); ssize_t (*read) (struct file *, char *, size_t, loff_t *);

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Apr 23 2000 - 21:00:19 EST