

Before:
        1.09s user 4.92s system 99% cpu 6.014 total
        0.74s user 5.28s system 99% cpu 6.023 total
        1.03s user 4.97s system 100% cpu 5.991 total

After:
	0.79s user 5.17s system 99% cpu 5.993 total
	0.79s user 5.17s system 100% cpu 5.957 total
	0.84s user 5.11s system 100% cpu 5.942 total




 drivers/char/tty_io.c     |    4 ++--
 fs/exec.c                 |    8 ++++----
 fs/fcntl.c                |   22 +++++++++++-----------
 fs/file.c                 |   24 ++++++++++++------------
 fs/file_table.c           |    4 ++--
 fs/open.c                 |   18 +++++++++---------
 fs/proc/base.c            |   28 ++++++++++++++--------------
 fs/select.c               |    4 ++--
 include/linux/file.h      |    2 +-
 include/linux/init_task.h |    2 +-
 kernel/fork.c             |   18 +++++++++---------
 11 files changed, 67 insertions(+), 67 deletions(-)

diff -puN drivers/char/tty_io.c~file_lock-spinlock drivers/char/tty_io.c
--- 25/drivers/char/tty_io.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/drivers/char/tty_io.c	2003-04-08 03:16:33.000000000 -0700
@@ -1881,7 +1881,7 @@ static void __do_SAK(void *arg)
 		}
 		task_lock(p);
 		if (p->files) {
-			read_lock(&p->files->file_lock);
+			spin_lock(&p->files->file_lock);
 			for (i=0; i < p->files->max_fds; i++) {
 				filp = fcheck_files(p->files, i);
 				if (filp && (filp->f_op == &tty_fops) &&
@@ -1893,7 +1893,7 @@ static void __do_SAK(void *arg)
 					break;
 				}
 			}
-			read_unlock(&p->files->file_lock);
+			spin_unlock(&p->files->file_lock);
 		}
 		task_unlock(p);
 	}
diff -puN fs/exec.c~file_lock-spinlock fs/exec.c
--- 25/fs/exec.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/exec.c	2003-04-08 03:16:33.000000000 -0700
@@ -750,7 +750,7 @@ static inline void flush_old_files(struc
 {
 	long j = -1;
 
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	for (;;) {
 		unsigned long set, i;
 
@@ -762,16 +762,16 @@ static inline void flush_old_files(struc
 		if (!set)
 			continue;
 		files->close_on_exec->fds_bits[j] = 0;
-		write_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		for ( ; set ; i++,set >>= 1) {
 			if (set & 1) {
 				sys_close(i);
 			}
 		}
-		write_lock(&files->file_lock);
+		spin_lock(&files->file_lock);
 
 	}
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 }
 
 int flush_old_exec(struct linux_binprm * bprm)
diff -puN fs/fcntl.c~file_lock-spinlock fs/fcntl.c
--- 25/fs/fcntl.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/fcntl.c	2003-04-08 03:16:33.000000000 -0700
@@ -23,21 +23,21 @@ extern int fcntl_getlease(struct file *f
 void set_close_on_exec(unsigned int fd, int flag)
 {
 	struct files_struct *files = current->files;
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (flag)
 		FD_SET(fd, files->close_on_exec);
 	else
 		FD_CLR(fd, files->close_on_exec);
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 }
 
 static inline int get_close_on_exec(unsigned int fd)
 {
 	struct files_struct *files = current->files;
 	int res;
-	read_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	res = FD_ISSET(fd, files->close_on_exec);
-	read_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	return res;
 }
 
@@ -134,15 +134,15 @@ static int dupfd(struct file *file, int 
 	struct files_struct * files = current->files;
 	int fd;
 
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	fd = locate_fd(files, file, start);
 	if (fd >= 0) {
 		FD_SET(fd, files->open_fds);
 		FD_CLR(fd, files->close_on_exec);
-		write_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		fd_install(fd, file);
 	} else {
-		write_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		fput(file);
 	}
 
@@ -155,7 +155,7 @@ asmlinkage long sys_dup2(unsigned int ol
 	struct file * file, *tofree;
 	struct files_struct * files = current->files;
 
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (!(file = fcheck(oldfd)))
 		goto out_unlock;
 	err = newfd;
@@ -186,7 +186,7 @@ asmlinkage long sys_dup2(unsigned int ol
 	files->fd[newfd] = file;
 	FD_SET(newfd, files->open_fds);
 	FD_CLR(newfd, files->close_on_exec);
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 
 	if (tofree)
 		filp_close(tofree, files);
@@ -194,11 +194,11 @@ asmlinkage long sys_dup2(unsigned int ol
 out:
 	return err;
 out_unlock:
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	goto out;
 
 out_fput:
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	fput(file);
 	goto out;
 }
diff -puN fs/file.c~file_lock-spinlock fs/file.c
--- 25/fs/file.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/file.c	2003-04-08 03:16:33.000000000 -0700
@@ -65,7 +65,7 @@ int expand_fd_array(struct files_struct 
 		goto out;
 
 	nfds = files->max_fds;
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 
 	/* 
 	 * Expand to the max in easy steps, and keep expanding it until
@@ -89,7 +89,7 @@ int expand_fd_array(struct files_struct 
 
 	error = -ENOMEM;
 	new_fds = alloc_fd_array(nfds);
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (!new_fds)
 		goto out;
 
@@ -110,15 +110,15 @@ int expand_fd_array(struct files_struct 
 			memset(&new_fds[i], 0,
 			       (nfds-i) * sizeof(struct file *)); 
 
-			write_unlock(&files->file_lock);
+			spin_unlock(&files->file_lock);
 			free_fd_array(old_fds, i);
-			write_lock(&files->file_lock);
+			spin_lock(&files->file_lock);
 		}
 	} else {
 		/* Somebody expanded the array while we slept ... */
-		write_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		free_fd_array(new_fds, nfds);
-		write_lock(&files->file_lock);
+		spin_lock(&files->file_lock);
 	}
 	error = 0;
 out:
@@ -167,7 +167,7 @@ int expand_fdset(struct files_struct *fi
 		goto out;
 
 	nfds = files->max_fdset;
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 
 	/* Expand to the max in easy steps */
 	do {
@@ -183,7 +183,7 @@ int expand_fdset(struct files_struct *fi
 	error = -ENOMEM;
 	new_openset = alloc_fdset(nfds);
 	new_execset = alloc_fdset(nfds);
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (!new_openset || !new_execset)
 		goto out;
 
@@ -208,21 +208,21 @@ int expand_fdset(struct files_struct *fi
 		nfds = xchg(&files->max_fdset, nfds);
 		new_openset = xchg(&files->open_fds, new_openset);
 		new_execset = xchg(&files->close_on_exec, new_execset);
-		write_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		free_fdset (new_openset, nfds);
 		free_fdset (new_execset, nfds);
-		write_lock(&files->file_lock);
+		spin_lock(&files->file_lock);
 		return 0;
 	} 
 	/* Somebody expanded the array while we slept ... */
 
 out:
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	if (new_openset)
 		free_fdset(new_openset, nfds);
 	if (new_execset)
 		free_fdset(new_execset, nfds);
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	return error;
 }
 
diff -puN fs/file_table.c~file_lock-spinlock fs/file_table.c
--- 25/fs/file_table.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/file_table.c	2003-04-08 03:16:33.000000000 -0700
@@ -182,11 +182,11 @@ struct file *fget(unsigned int fd)
 	struct file *file;
 	struct files_struct *files = current->files;
 
-	read_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	file = fcheck(fd);
 	if (file)
 		get_file(file);
-	read_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	return file;
 }
 
diff -puN fs/open.c~file_lock-spinlock fs/open.c
--- 25/fs/open.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/open.c	2003-04-08 03:16:33.000000000 -0700
@@ -702,7 +702,7 @@ int get_unused_fd(void)
 	int fd, error;
 
   	error = -EMFILE;
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 
 repeat:
  	fd = find_next_zero_bit(files->open_fds->fds_bits, 
@@ -751,7 +751,7 @@ repeat:
 	error = fd;
 
 out:
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	return error;
 }
 
@@ -765,9 +765,9 @@ static inline void __put_unused_fd(struc
 void put_unused_fd(unsigned int fd)
 {
 	struct files_struct *files = current->files;
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	__put_unused_fd(files, fd);
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 }
 
 /*
@@ -786,11 +786,11 @@ void put_unused_fd(unsigned int fd)
 void fd_install(unsigned int fd, struct file * file)
 {
 	struct files_struct *files = current->files;
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (unlikely(files->fd[fd] != NULL))
 		BUG();
 	files->fd[fd] = file;
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 }
 
 asmlinkage long sys_open(const char * filename, int flags, int mode)
@@ -870,7 +870,7 @@ asmlinkage long sys_close(unsigned int f
 	struct file * filp;
 	struct files_struct *files = current->files;
 
-	write_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	if (fd >= files->max_fds)
 		goto out_unlock;
 	filp = files->fd[fd];
@@ -879,11 +879,11 @@ asmlinkage long sys_close(unsigned int f
 	files->fd[fd] = NULL;
 	FD_CLR(fd, files->close_on_exec);
 	__put_unused_fd(files, fd);
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	return filp_close(filp, files);
 
 out_unlock:
-	write_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	return -EBADF;
 }
 
diff -puN fs/proc/base.c~file_lock-spinlock fs/proc/base.c
--- 25/fs/proc/base.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/proc/base.c	2003-04-08 03:16:33.000000000 -0700
@@ -117,16 +117,16 @@ static int proc_fd_link(struct inode *in
 		atomic_inc(&files->count);
 	task_unlock(task);
 	if (files) {
-		read_lock(&files->file_lock);
+		spin_lock(&files->file_lock);
 		file = fcheck_files(files, fd);
 		if (file) {
 			*mnt = mntget(file->f_vfsmnt);
 			*dentry = dget(file->f_dentry);
-			read_unlock(&files->file_lock);
+			spin_unlock(&files->file_lock);
 			put_files_struct(files);
 			return 0;
 		}
-		read_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		put_files_struct(files);
 	}
 	return -ENOENT;
@@ -655,7 +655,7 @@ static int proc_readfd(struct file * fil
 			task_unlock(p);
 			if (!files)
 				goto out;
-			read_lock(&files->file_lock);
+			spin_lock(&files->file_lock);
 			for (fd = filp->f_pos-2;
 			     fd < files->max_fds;
 			     fd++, filp->f_pos++) {
@@ -663,7 +663,7 @@ static int proc_readfd(struct file * fil
 
 				if (!fcheck_files(files, fd))
 					continue;
-				read_unlock(&files->file_lock);
+				spin_unlock(&files->file_lock);
 
 				j = NUMBUF;
 				i = fd;
@@ -675,12 +675,12 @@ static int proc_readfd(struct file * fil
 
 				ino = fake_ino(pid, PROC_PID_FD_DIR + fd);
 				if (filldir(dirent, buf+j, NUMBUF-j, fd+2, ino, DT_LNK) < 0) {
-					read_lock(&files->file_lock);
+					spin_lock(&files->file_lock);
 					break;
 				}
-				read_lock(&files->file_lock);
+				spin_lock(&files->file_lock);
 			}
-			read_unlock(&files->file_lock);
+			spin_unlock(&files->file_lock);
 			put_files_struct(files);
 	}
 out:
@@ -824,13 +824,13 @@ static int pid_fd_revalidate(struct dent
 		atomic_inc(&files->count);
 	task_unlock(task);
 	if (files) {
-		read_lock(&files->file_lock);
+		spin_lock(&files->file_lock);
 		if (fcheck_files(files, fd)) {
-			read_unlock(&files->file_lock);
+			spin_unlock(&files->file_lock);
 			put_files_struct(files);
 			return 1;
 		}
-		read_unlock(&files->file_lock);
+		spin_unlock(&files->file_lock);
 		put_files_struct(files);
 	}
 	d_drop(dentry);
@@ -920,7 +920,7 @@ static struct dentry *proc_lookupfd(stru
 	if (!files)
 		goto out_unlock;
 	inode->i_mode = S_IFLNK;
-	read_lock(&files->file_lock);
+	spin_lock(&files->file_lock);
 	file = fcheck_files(files, fd);
 	if (!file)
 		goto out_unlock2;
@@ -928,7 +928,7 @@ static struct dentry *proc_lookupfd(stru
 		inode->i_mode |= S_IRUSR | S_IXUSR;
 	if (file->f_mode & 2)
 		inode->i_mode |= S_IWUSR | S_IXUSR;
-	read_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	put_files_struct(files);
 	inode->i_op = &proc_pid_link_inode_operations;
 	inode->i_size = 64;
@@ -940,7 +940,7 @@ static struct dentry *proc_lookupfd(stru
 	return NULL;
 
 out_unlock2:
-	read_unlock(&files->file_lock);
+	spin_unlock(&files->file_lock);
 	put_files_struct(files);
 out_unlock:
 	iput(inode);
diff -puN fs/select.c~file_lock-spinlock fs/select.c
--- 25/fs/select.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/fs/select.c	2003-04-08 03:16:33.000000000 -0700
@@ -179,9 +179,9 @@ int do_select(int n, fd_set_bits *fds, l
 	int retval, i, off;
 	long __timeout = *timeout;
 
- 	read_lock(&current->files->file_lock);
+ 	spin_lock(&current->files->file_lock);
 	retval = max_select_fd(n, fds);
-	read_unlock(&current->files->file_lock);
+	spin_unlock(&current->files->file_lock);
 
 	if (retval < 0)
 		return retval;
diff -puN include/linux/file.h~file_lock-spinlock include/linux/file.h
--- 25/include/linux/file.h~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/include/linux/file.h	2003-04-08 03:16:33.000000000 -0700
@@ -21,7 +21,7 @@
  */
 struct files_struct {
         atomic_t count;
-        rwlock_t file_lock;     /* Protects all the below members.  Nests inside tsk->alloc_lock */
+        spinlock_t file_lock;     /* Protects all the below members.  Nests inside tsk->alloc_lock */
         int max_fds;
         int max_fdset;
         int next_fd;
diff -puN include/linux/init_task.h~file_lock-spinlock include/linux/init_task.h
--- 25/include/linux/init_task.h~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/include/linux/init_task.h	2003-04-08 03:16:33.000000000 -0700
@@ -6,7 +6,7 @@
 #define INIT_FILES \
 { 							\
 	.count		= ATOMIC_INIT(1), 		\
-	.file_lock	= RW_LOCK_UNLOCKED, 		\
+	.file_lock	= SPIN_LOCK_UNLOCKED, 		\
 	.max_fds	= NR_OPEN_DEFAULT, 		\
 	.max_fdset	= __FD_SETSIZE, 		\
 	.next_fd	= 0, 				\
diff -puN kernel/fork.c~file_lock-spinlock kernel/fork.c
--- 25/kernel/fork.c~file_lock-spinlock	2003-04-08 03:16:33.000000000 -0700
+++ 25-akpm/kernel/fork.c	2003-04-08 03:16:33.000000000 -0700
@@ -603,7 +603,7 @@ static int copy_files(unsigned long clon
 
 	atomic_set(&newf->count, 1);
 
-	newf->file_lock	    = RW_LOCK_UNLOCKED;
+	newf->file_lock	    = SPIN_LOCK_UNLOCKED;
 	newf->next_fd	    = 0;
 	newf->max_fds	    = NR_OPEN_DEFAULT;
 	newf->max_fdset	    = __FD_SETSIZE;
@@ -616,13 +616,13 @@ static int copy_files(unsigned long clon
 	size = oldf->max_fdset;
 	if (size > __FD_SETSIZE) {
 		newf->max_fdset = 0;
-		write_lock(&newf->file_lock);
+		spin_lock(&newf->file_lock);
 		error = expand_fdset(newf, size-1);
-		write_unlock(&newf->file_lock);
+		spin_unlock(&newf->file_lock);
 		if (error)
 			goto out_release;
 	}
-	read_lock(&oldf->file_lock);
+	spin_lock(&oldf->file_lock);
 
 	open_files = count_open_files(oldf, size);
 
@@ -633,15 +633,15 @@ static int copy_files(unsigned long clon
 	 */
 	nfds = NR_OPEN_DEFAULT;
 	if (open_files > nfds) {
-		read_unlock(&oldf->file_lock);
+		spin_unlock(&oldf->file_lock);
 		newf->max_fds = 0;
-		write_lock(&newf->file_lock);
+		spin_lock(&newf->file_lock);
 		error = expand_fd_array(newf, open_files-1);
-		write_unlock(&newf->file_lock);
+		spin_unlock(&newf->file_lock);
 		if (error) 
 			goto out_release;
 		nfds = newf->max_fds;
-		read_lock(&oldf->file_lock);
+		spin_lock(&oldf->file_lock);
 	}
 
 	old_fds = oldf->fd;
@@ -656,7 +656,7 @@ static int copy_files(unsigned long clon
 			get_file(f);
 		*new_fds++ = f;
 	}
-	read_unlock(&oldf->file_lock);
+	spin_unlock(&oldf->file_lock);
 
 	/* compute the remainder to be cleared */
 	size = (newf->max_fds - open_files) * sizeof(struct file *);

_
