From: Andrew Morton <akpm@osdl.org>
To: Peter Chubb <peterc@gelato.unsw.edu.au>
Cc: linux-kernel@vger.kernel.org
Subject: Re: Why lock_kernel() in drivers/pci/proc.c (2.6.0-test9)??
Date: Tue, 18 Nov 2003 18:51:39 -0800 [thread overview]
Message-ID: <20031118185139.4edb2e8f.akpm@osdl.org> (raw)
In-Reply-To: <16314.54665.18373.588780@wombat.disy.cse.unsw.edu.au>
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
_
prev parent reply other threads:[~2003-11-19 2:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-11-19 2:29 Peter Chubb
2003-11-19 2:51 ` Andrew Morton [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20031118185139.4edb2e8f.akpm@osdl.org \
--to=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterc@gelato.unsw.edu.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®