From: Roland Dreier <rdreier@cisco.com>
To: Jonathan Corbet <corbet@lwn.net>
Cc: linux-kernel@vger.kernel.org, general@lists.openfabrics.org
Subject: [PATCH for bkl-removal] IB/umad: BKL is not needed for ib_umad_open()
Date: Fri, 11 Jul 2008 13:31:04 -0700 [thread overview]
Message-ID: <aday748mad3.fsf@cisco.com> (raw)
Remove explicit lock_kernel() calls and document why the code is safe.
Signed-off-by: Roland Dreier <rolandd@cisco.com>
---
Hi Jon, more BKL removal for your tree. Should be ready for 2.6.27.
diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c
index 260b3df..d31e5bb 100644
--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -47,7 +47,6 @@
#include <linux/kref.h>
#include <linux/compat.h>
#include <linux/semaphore.h>
-#include <linux/smp_lock.h>
#include <asm/uaccess.h>
@@ -778,23 +777,33 @@ static long ib_umad_compat_ioctl(struct file *filp, unsigned int cmd,
}
#endif
+/*
+ * ib_umad_open() does not need the BKL:
+ *
+ * - umad_port[] accesses are protected by port_lock, the
+ * ib_umad_port structures are properly reference counted, and
+ * everything else is purely local to the file being created, so
+ * races against other open calls are not a proble;
+ * - the ioctl method does not affect any global state outside of the
+ * file structure being operated on;
+ * - the port is added to umad_port[] as the last part of module
+ * initialization so the open method will either immediately run
+ * -ENXIO, or all required initialization will be done.
+ */
static int ib_umad_open(struct inode *inode, struct file *filp)
{
struct ib_umad_port *port;
struct ib_umad_file *file;
int ret = 0;
- lock_kernel();
spin_lock(&port_lock);
port = umad_port[iminor(inode) - IB_UMAD_MINOR_BASE];
if (port)
kref_get(&port->umad_dev->ref);
spin_unlock(&port_lock);
- if (!port) {
- unlock_kernel();
+ if (!port)
return -ENXIO;
- }
mutex_lock(&port->file_mutex);
@@ -823,7 +832,6 @@ static int ib_umad_open(struct inode *inode, struct file *filp)
out:
mutex_unlock(&port->file_mutex);
- unlock_kernel();
return ret;
}
next reply other threads:[~2008-07-11 20:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-07-11 20:31 Roland Dreier [this message]
2008-07-11 20:54 ` [PATCH for bkl-removal v2] IB/umad: BKL is not needed for ib_umad_open() Roland Dreier
2008-07-11 22:42 ` Jonathan Corbet
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=aday748mad3.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=corbet@lwn.net \
--cc=general@lists.openfabrics.org \
--cc=linux-kernel@vger.kernel.org \
/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