lkml.org 
[lkml]   [2003]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: Why lock_kernel() in drivers/pci/proc.c (2.6.0-test9)??
Peter Chubb <peterc@gelato.unsw.edu.au> wrote:
>
>
> Hi,
> What is the BKL protecting in
> drivers/pci/proc.c:proc_bus_pci_lseek() ?

nothing much.

> It looks useless to me, as file->f_pos is changed outside the lock
> anyway, and all the other variables inside the locked region are
> effectively constants for the purpose of this code.
>
> So unless something subtle's going on, I suggest this:
>

We normally use i_sem to prevent parallel lseeks against the same fd from
scribbling on f_pos. Which seems fairly pointless since parallel reads
aren't using i_sem.

But this would be a more conventional debklification. Does it work OK?


drivers/pci/proc.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)

diff -puN drivers/pci/proc.c~proc_bus_pci_lseek-remove-lock_kernel drivers/pci/proc.c
--- 25/drivers/pci/proc.c~proc_bus_pci_lseek-remove-lock_kernel 2003-11-18 18:47:20.000000000 -0800
+++ 25-akpm/drivers/pci/proc.c 2003-11-18 18:48:16.000000000 -0800
@@ -25,7 +25,7 @@ proc_bus_pci_lseek(struct file *file, lo
{
loff_t new = -1;

- lock_kernel();
+ down(&file->f_dentry->d_inode->i_sem);
switch (whence) {
case 0:
new = off;
@@ -37,10 +37,12 @@ proc_bus_pci_lseek(struct file *file, lo
new = PCI_CFG_SPACE_SIZE + off;
break;
}
- unlock_kernel();
if (new < 0 || new > PCI_CFG_SPACE_SIZE)
- return -EINVAL;
- return (file->f_pos = new);
+ new = -EINVAL;
+ else
+ file->f_pos = new;
+ up(&file->f_dentry->d_inode->i_sem);
+ return new;
}

static ssize_t
_

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

\
 
 \ /
  Last update: 2005-03-22 13:58    [W:0.239 / U:0.196 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site