From: Frederic Weisbecker <fweisbec@gmail.com>
To: Greg Kroah-Hartman <gregkh@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>,
Frederic Weisbecker <fweisbec@gmail.com>,
Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
John Kacur <jkacur@redhat.com>,
Sven-Thorsten Dietrich <sven@thebigcorporation.com>,
Jonathan Corbet <corbet@lwn.net>,
Alessio Igor Bogani <abogani@texware.it>
Subject: [PATCH] mem_class: Drop the bkl from memory_open()
Date: Fri, 9 Oct 2009 20:31:02 +0200 [thread overview]
Message-ID: <1255113062-5835-1-git-send-email-fweisbec@gmail.com> (raw)
The generic open callback for the mem class devices is "protected" by
the bkl.
Let's look at the datas manipulated inside memory_open:
- inode and file: safe
- the devlist: safe because it is constant
- the memdev classes inside this array are safe too (constant)
After we find out which memdev file operation we need to use, we call
its open callback. Depending on the targeted memdev, we call either
open_port() that doesn't manipulate any racy data (just a capable()
check), or we call nothing.
So it's safe to remove the big kernel lock there.
Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: John Kacur <jkacur@redhat.com>
Cc: Sven-Thorsten Dietrich <sven@thebigcorporation.com>
Cc: Jonathan Corbet <corbet@lwn.net>
Cc: Alessio Igor Bogani <abogani@texware.it>
---
drivers/char/mem.c | 16 +++++-----------
1 files changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/char/mem.c b/drivers/char/mem.c
index a074fce..599846a 100644
--- a/drivers/char/mem.c
+++ b/drivers/char/mem.c
@@ -892,29 +892,23 @@ static int memory_open(struct inode *inode, struct file *filp)
{
int minor;
const struct memdev *dev;
- int ret = -ENXIO;
-
- lock_kernel();
minor = iminor(inode);
if (minor >= ARRAY_SIZE(devlist))
- goto out;
+ return -ENXIO;
dev = &devlist[minor];
if (!dev->fops)
- goto out;
+ return -ENXIO;
filp->f_op = dev->fops;
if (dev->dev_info)
filp->f_mapping->backing_dev_info = dev->dev_info;
if (dev->fops->open)
- ret = dev->fops->open(inode, filp);
- else
- ret = 0;
-out:
- unlock_kernel();
- return ret;
+ return dev->fops->open(inode, filp);
+
+ return 0;
}
static const struct file_operations memory_fops = {
--
1.6.2.3
next reply other threads:[~2009-10-09 18:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-09 18:31 Frederic Weisbecker [this message]
2009-10-09 18:34 ` Thomas Gleixner
2009-10-14 15:48 ` [tip:bkl/drivers] " tip-bot for Frederic Weisbecker
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=1255113062-5835-1-git-send-email-fweisbec@gmail.com \
--to=fweisbec@gmail.com \
--cc=abogani@texware.it \
--cc=corbet@lwn.net \
--cc=gregkh@suse.de \
--cc=jkacur@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=sven@thebigcorporation.com \
--cc=tglx@linutronix.de \
/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®