Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756088AbZJLKoc (ORCPT ); Mon, 12 Oct 2009 06:44:32 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1755249AbZJLKoc (ORCPT ); Mon, 12 Oct 2009 06:44:32 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6558 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755238AbZJLKob (ORCPT ); Mon, 12 Oct 2009 06:44:31 -0400 Date: Mon, 12 Oct 2009 12:42:39 +0200 (CEST) From: John Kacur X-X-Sender: jkacur@localhost.localdomain To: Takashi Iwai cc: Frederic Weisbecker , Alan Cox , linux-kernel@vger.kernel.org, Thomas Gleixner , Jonathan Corbet , Peter Zijlstra , Christoph Hellwig , Andrew Morton , Vincent^M^J Sanders , Ingo Molnar Subject: Re: [PATCH] sound_core.c: Remove BKL from soundcore_open In-Reply-To: Message-ID: References: <20091011004219.74c30f67@lxorguk.ukuu.org.uk> <20091011113317.GA4901@nowhere> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4279 Lines: 139 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 > > 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 > > Acked-by: Alan Cox > > --- > > 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 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 Acked-by: Alan Cox --- 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 -- 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/