remove BKL from llseek
Subsystems (4)
PATCH 1/1 remove BKL from llseek
Hi,
The dbench-o-matic results from removing the BKL from llseek can be found here:
http://samba.org/~anton/linux/llseek/
Same hardware as the earlier test, 12 way ppc64. The patch is pretty dumb, I just pushed the kernel lock down into the llseek methods and only replaced it with the inode semaphore in generic_llseek. Im sure Al will have a better fix for 2.5, I just wanted to highlight the problem :)
Anton
fs/block_dev.c +3 -0
@@ -149,6 +149,8 @@loff_t size = file->f_dentry->d_inode->i_bdev->bd_inode->i_size;loff_t retval; +lock_kernel (); +switch (origin) {case 2 : offset += size;
@@ -165,6 +167,7 @@ } retval = offset; } +unlock_kernel ();return retval; }
fs/hfs/file_cap.c +3 -0
@@ -91,6 +91,8 @@ {long long retval; +lock_kernel (); +switch (origin) {case 2 : offset += file->f_dentry->d_inode->i_size;
@@ -107,6 +109,7 @@ } retval = offset; } +unlock_kernel ();return retval; }
fs/hfs/file_hdr.c +3 -0
@@ -347,6 +347,8 @@ {long long retval; +lock_kernel (); +switch (origin) {case 2 : offset += file->f_dentry->d_inode->i_size;
@@ -363,6 +365,7 @@ } retval = offset; } +unlock_kernel ();return retval; }
fs/hpfs/dir.c +5 -0
@@ -28,6 +28,9 @@struct quad_buffer_head qbh;struct inode *i = filp->f_dentry->d_inode;struct super_block *s = i->i_sb; + +lock_kernel (); +/*printk("dir lseek\n");*/ if (new_off ==0 || new_off ==1 || new_off ==11 || new_off ==12 || new_off ==13 ) goto ok;hpfs_lock_inode (i);
@@ -39,10 +42,12 @@ }hpfs_unlock_inode (i); ok: +unlock_kernel ();return filp->f_pos = new_off; fail:hpfs_unlock_inode (i);/*printk("illegal lseek: %016llx\n", new_off);*/ +unlock_kernel ();return -ESPIPE ; }
fs/proc/generic.c +13 -4
@@ -16,6 +16,7 @@#include <linux/stat.h> #define __NO_VERSION__#include <linux/module.h> +#include <linux/smp_lock.h> #include <asm/bitops.h> static ssize_t proc_file_read(struct file * file, char * buf,
@@ -140,22 +141,30 @@static loff_t proc_file_lseek (struct file * file,loff_t offset,int orig) { +lock_kernel (); +switch (orig) {case 0 :if (offset <0 ) -return -EINVAL ; + goto out_err; file->f_pos = offset; +unlock_kernel ();return (file->f_pos);case 1 :if (offset + file->f_pos <0 ) -return -EINVAL ; + goto out_err; file->f_pos += offset; +unlock_kernel ();return (file->f_pos);case 2 : -return (-EINVAL ); + goto out_err;default : -return (-EINVAL ); + goto out_err; } + +out_err: +unlock_kernel (); +return -EINVAL ; }/*
fs/read_write.c +6 -2
@@ -29,6 +29,8 @@ {long long retval; +down (&file->f_dentry->d_inode->i_sem); +switch (origin) {case 2 : offset += file->f_dentry->d_inode->i_size;
@@ -45,6 +47,7 @@ } retval = offset; } +up (&file->f_dentry->d_inode->i_sem);return retval; }
@@ -57,6 +60,8 @@ {long long retval; +lock_kernel (); +switch (origin) {case 2 : offset += file->f_dentry->d_inode->i_size;
@@ -73,6 +78,7 @@ } retval = offset; } +unlock_kernel ();return retval; }
@@ -84,9 +90,7 @@ fn = default_llseek;if (file->f_op && file->f_op->llseek) fn = file->f_op->llseek; -lock_kernel (); retval =fn (file, offset, origin); -unlock_kernel ();return retval; }
fs/ufs/file.c +3 -0
@@ -47,6 +47,8 @@long long retval;struct inode *inode = file->f_dentry->d_inode; +lock_kernel (); +switch (origin) {case 2 : offset += inode->i_size;
@@ -64,6 +66,7 @@ } retval = offset; } +unlock_kernel ();return retval; }
Quoted 10 lines · Anton Blanchard
The dbench-o-matic results from removing the BKL from llseek can be found here:
http://samba.org/~anton/linux/llseek/
Same hardware as the earlier test, 12 way ppc64. The patch is pretty dumb, I just pushed the kernel lock down into the llseek methods and only replaced it with the inode semaphore in
generic_llseek. Im sure Al will have a better fix for 2.5, I just wanted to highlight the problem :)
yeah i did that once (about a year ago or more) and it was rejected, cant remember why :-) But it's indeed an important optimization and it shows up in dbench overhead.
Ingo