From: John Kacur <jkacur@redhat.com>
To: Takashi Iwai <tiwai@suse.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>,
Alan Cox <alan@lxorguk.ukuu.org.uk>,
linux-kernel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
Jonathan Corbet <corbet@lwn.net>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Christoph Hellwig <hch@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Vincent^M^J Sanders <vince@simtec.co.uk>,
Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] sound_core.c: Remove BKL from soundcore_open
Date: Mon, 12 Oct 2009 12:42:39 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.0910121241040.3658@localhost.localdomain> (raw)
In-Reply-To: <s5hr5t8ex1j.wl%tiwai@suse.de>
On Mon, 12 Oct 2009, Takashi Iwai wrote:
> At Mon, 12 Oct 2009 10:37:05 +0200 (CEST),
> John Kacur wrote:
> >
> > On Mon, 12 Oct 2009, Takashi Iwai wrote:
> >
> > > At Sun, 11 Oct 2009 14:41:15 +0200 (CEST),
> > > John Kacur wrote:
> > > >
> > > > @@ -631,17 +629,17 @@ static int soundcore_open(struct inode *inode, struct file *file)
> > > > file->f_op = new_fops;
> > > > spin_unlock(&sound_loader_lock);
> > > > if(file->f_op->open)
> > > > + lock_kernel();
> > > > err = file->f_op->open(inode,file);
> > > > + unlock_kernel();
> > >
> > > You certainly want braces around here, no?
> > >
> >
> > Oh, I don't know, I was kinda hoping that the spaces would magically
> > impart bracketnishish to the whole thing. My God yes we want the brackets -
> > Thank you Takashi!
> >
> > What follows is version four.
> >
> > >From 90f527d2ae660a3a0e712075479a4cc24504ad45 Mon Sep 17 00:00:00 2001
> > From: John Kacur <jkacur@redhat.com>
> > Date: Sun, 11 Oct 2009 14:25:46 +0200
> > Subject: [PATCH] soundcore_open: Reduce the area BKL coverage in this function.
> >
> > Most of this function is protected by the sound_loader_lock.
> > We can push down the BKL to this call out err = file->f_op->open(inode,file);
> >
> > Signed-off-by: John Kacur <jkacur@redhat.com>
> > Acked-by: Alan Cox <alan@linux.intel.com>
> > ---
> > sound/sound_core.c | 10 ++++------
> > 1 files changed, 4 insertions(+), 6 deletions(-)
> >
> > diff --git a/sound/sound_core.c b/sound/sound_core.c
> > index 49c9981..643a61f 100644
> > --- a/sound/sound_core.c
> > +++ b/sound/sound_core.c
> > @@ -576,8 +576,6 @@ static int soundcore_open(struct inode *inode, struct file *file)
> > struct sound_unit *s;
> > const struct file_operations *new_fops = NULL;
> >
> > - lock_kernel ();
> > -
> > chain=unit&0x0F;
> > if(chain==4 || chain==5) /* dsp/audio/dsp16 */
> > {
> > @@ -630,18 +628,18 @@ static int soundcore_open(struct inode *inode, struct file *file)
> > const struct file_operations *old_fops = file->f_op;
> > file->f_op = new_fops;
> > spin_unlock(&sound_loader_lock);
> > - if(file->f_op->open)
> > + if(file->f_op->open) {
> > + lock_kernel();
> > err = file->f_op->open(inode,file);
> > - if (err) {
> > + unlock_kernel();
> > + } if (err) {
>
> It's better to break the line after the closing brace here.
>
Thank you for your review Takashi.
I corrected the style problems, and added a bit of spacing to make the
code more readable.
Version 5 follows
>From 8007707e02f68b6315ff80aa3ca471af12eeb491 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Sun, 11 Oct 2009 14:25:46 +0200
Subject: [PATCH] soundcore_open: Reduce the area BKL coverage in this function.
Most of this function is protected by the sound_loader_lock.
We can push down the BKL to this call out err = file->f_op->open(inode,file);
Signed-off-by: John Kacur <jkacur@redhat.com>
Acked-by: Alan Cox <alan@linux.intel.com>
---
sound/sound_core.c | 12 +++++++-----
1 files changed, 7 insertions(+), 5 deletions(-)
diff --git a/sound/sound_core.c b/sound/sound_core.c
index 49c9981..2ca17ec 100644
--- a/sound/sound_core.c
+++ b/sound/sound_core.c
@@ -576,8 +576,6 @@ static int soundcore_open(struct inode *inode, struct file *file)
struct sound_unit *s;
const struct file_operations *new_fops = NULL;
- lock_kernel ();
-
chain=unit&0x0F;
if(chain==4 || chain==5) /* dsp/audio/dsp16 */
{
@@ -630,18 +628,22 @@ static int soundcore_open(struct inode *inode, struct file *file)
const struct file_operations *old_fops = file->f_op;
file->f_op = new_fops;
spin_unlock(&sound_loader_lock);
- if(file->f_op->open)
+
+ if (file->f_op->open) {
+ lock_kernel();
err = file->f_op->open(inode,file);
+ unlock_kernel();
+ }
+
if (err) {
fops_put(file->f_op);
file->f_op = fops_get(old_fops);
}
+
fops_put(old_fops);
- unlock_kernel();
return err;
}
spin_unlock(&sound_loader_lock);
- unlock_kernel();
return -ENODEV;
}
--
1.6.0.6
next prev parent reply other threads:[~2009-10-12 10:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-10 23:24 [PATCH] sound_core.c: Remove BKL from soundcore_open John Kacur
2009-10-10 23:42 ` Alan Cox
2009-10-11 0:25 ` John Kacur
2009-10-11 11:33 ` Frederic Weisbecker
2009-10-11 12:41 ` John Kacur
2009-10-11 14:12 ` Oliver Neukum
2009-10-11 20:40 ` Frederic Weisbecker
2009-10-11 21:25 ` John Kacur
2009-10-12 6:05 ` Takashi Iwai
2009-10-12 8:37 ` John Kacur
2009-10-12 10:17 ` Takashi Iwai
2009-10-12 10:42 ` John Kacur [this message]
2009-10-11 15:20 ` Jonathan Corbet
2009-10-11 17:15 ` Jonathan Corbet
2009-10-11 17:37 ` Arjan van de Ven
2009-10-11 19:17 ` Alan Cox
2009-10-11 19:26 ` Arjan van de Ven
2009-10-11 20:51 ` Alan Cox
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=alpine.LFD.2.00.0910121241040.3658@localhost.localdomain \
--to=jkacur@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=corbet@lwn.net \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=tiwai@suse.de \
--cc=vince@simtec.co.uk \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.