|
|
| Next: Bug#550491: Please fix Homepage for ripit |
| Author |
Message |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 00/28] BKL removal queued patches Archived from groups: linux>kernel (more info?) |
|
|
Hi all,
I'm sending out the pending BKL removal patches which I collected so
far to avoid duplicate work and to solicit review/comments.
If nobody objects I'd like to keep them in one git branch which is
going to be included into linux-next.
Thanks,
tglx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 14/28] um: Remove BKL from random [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_kernel_lock() was added during the big BKL pushdown. It should
ensure the serializiation against driver init code. In this case there
is nothing to serialize. Remove it.
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
Cc: Jeff Dike <jdike DeleteThis @addtoit.com>
---
arch/um/drivers/random.c | 3 ---
1 file changed, 3 deletions(-)
Index: linux-2.6-tip/arch/um/drivers/random.c
===================================================================
--- linux-2.6-tip.orig/arch/um/drivers/random.c
+++ linux-2.6-tip/arch/um/drivers/random.c
@@ -7,7 +7,6 @@
* of the GNU General Public License, incorporated herein by reference.
*/
#include <linux/sched.h>
-#include <linux/smp_lock.h>
#include <linux/module.h>
#include <linux/fs.h>
#include <linux/interrupt.h>
@@ -34,8 +33,6 @@ static DECLARE_WAIT_QUEUE_HEAD(host_read
static int rng_dev_open (struct inode *inode, struct file *filp)
{
- cycle_kernel_lock();
-
/* enforce read-only access to this chrdev */
if ((filp->f_mode & FMODE_READ) == 0)
return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 17/28] watchdog: Fix probe function of riowd [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
After sucessfully registering the misc device the driver iounmaps the
device registers and kfree's the device data structure. Ouch !
This was introduced with commit e42311d75 (riowatchdog: Convert to
pure OF driver) and went unnoticed for more than a year
Return success instead of dropping into the error cleanup code path.
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
Cc: David S. Miller <davem DeleteThis @davemloft.net>
---
drivers/watchdog/riowd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: linux-2.6-tip/drivers/watchdog/riowd.c
===================================================================
--- linux-2.6-tip.orig/drivers/watchdog/riowd.c
+++ linux-2.6-tip/drivers/watchdog/riowd.c
@@ -206,7 +206,7 @@ static int __devinit riowd_probe(struct
dev_set_drvdata(&op->dev, p);
riowd_device = p;
- err = 0;
+ return 0;
out_iounmap:
of_iounmap(&op->resource[0], p->regs, 2);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 05/28] drivers: Remove BKL from drivers/char/misc.c [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
misc_open() is already serialized with misc_mtx. Remove the BKL
locking which got there via the BKL pushdown.
Signed-off-by: Thomas Gleixner <tglx.RemoveThis@linutronix.de>
Cc: Greg Kroah-Hartman <gregkh.RemoveThis@suse.de>
---
drivers/char/misc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
Index: linux-2.6-tip/drivers/char/misc.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/misc.c
+++ linux-2.6-tip/drivers/char/misc.c
@@ -49,7 +49,6 @@
#include <linux/device.h>
#include <linux/tty.h>
#include <linux/kmod.h>
-#include <linux/smp_lock.h>
/*
* Head entry for the doubly linked miscdevice list
@@ -118,8 +117,7 @@ static int misc_open(struct inode * inod
struct miscdevice *c;
int err = -ENODEV;
const struct file_operations *old_fops, *new_fops = NULL;
-
- lock_kernel();
+
mutex_lock(&misc_mtx);
list_for_each_entry(c, &misc_list, list) {
@@ -157,7 +155,6 @@ static int misc_open(struct inode * inod
fops_put(old_fops);
fail:
mutex_unlock(&misc_mtx);
- unlock_kernel();
return err;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 23/28] i2c: Remove big kernel lock from i2cdev_open [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
The BKL is held over a kmalloc so cannot protect anything beyond that.
The two calls before the kmalloc have their own locking.
Improve device open function by removing the now unnecessary ret variable
Signed-off-by: Vincent Sanders <vince.RemoveThis@simtec.co.uk>
LKML-Reference: <1255175172-2666-1-git-send-email-vince.RemoveThis@simtec.co.uk>
Cc: Jean Delvare <khali.RemoveThis@linux-fr.org>
Signed-off-by: Thomas Gleixner <tglx.RemoveThis@linutronix.de>
---
drivers/i2c/i2c-dev.c | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
Index: linux-2.6-tip/drivers/i2c/i2c-dev.c
===================================================================
--- linux-2.6-tip.orig/drivers/i2c/i2c-dev.c
+++ linux-2.6-tip/drivers/i2c/i2c-dev.c
@@ -34,7 +34,6 @@
#include <linux/list.h>
#include <linux/i2c.h>
#include <linux/i2c-dev.h>
-#include <linux/smp_lock.h>
#include <linux/jiffies.h>
#include <asm/uaccess.h>
@@ -445,20 +444,14 @@ static int i2cdev_open(struct inode *ino
struct i2c_client *client;
struct i2c_adapter *adap;
struct i2c_dev *i2c_dev;
- int ret = 0;
- lock_kernel();
i2c_dev = i2c_dev_get_by_minor(minor);
- if (!i2c_dev) {
- ret = -ENODEV;
- goto out;
- }
+ if (!i2c_dev)
+ return -ENODEV;
adap = i2c_get_adapter(i2c_dev->adap->nr);
- if (!adap) {
- ret = -ENODEV;
- goto out;
- }
+ if (!adap)
+ return -ENODEV;
/* This creates an anonymous i2c_client, which may later be
* pointed to some address using I2C_SLAVE or I2C_SLAVE_FORCE.
@@ -470,8 +463,7 @@ static int i2cdev_open(struct inode *ino
client = kzalloc(sizeof(*client), GFP_KERNEL);
if (!client) {
i2c_put_adapter(adap);
- ret = -ENOMEM;
- goto out;
+ return -ENOMEM;
}
snprintf(client->name, I2C_NAME_SIZE, "i2c-dev %d", adap->nr);
client->driver = &i2cdev_driver;
@@ -479,9 +471,7 @@ static int i2cdev_open(struct inode *ino
client->adapter = adap;
file->private_data = client;
-out:
- unlock_kernel();
- return ret;
+ return 0;
}
static int i2cdev_release(struct inode *inode, struct file *file)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 19/28] hw_random: Remove BKL from core [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
hw_random core is completely serialized with rng_mutex. No need for
the cycle_kernel_lock() magic.
Signed-off-by: Thomas Gleixner <tglx.DeleteThis@linutronix.de>
Cc: Herbert Xu <herbert.DeleteThis@gondor.apana.org.au>
---
drivers/char/hw_random/core.c | 1 -
1 file changed, 1 deletion(-)
Index: linux-2.6-tip/drivers/char/hw_random/core.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/hw_random/core.c
+++ linux-2.6-tip/drivers/char/hw_random/core.c
@@ -87,7 +87,6 @@ static int rng_dev_open(struct inode *in
return -EINVAL;
if (filp->f_mode & FMODE_WRITE)
return -EINVAL;
- cycle_kernel_lock();
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 15/28] um: Remove BKL from mmapper [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_kernel_lock() was added during the big BKL pushdown. It should
ensure the serializiation against driver init code.
mmapper_open() cannot be called before misc_register() succeeded, but
p_buf might be uninitialized.
Move the initialization of p_buf before the misc_register() call and
get rid of cycle_kernel_lock().
Signed-off-by: Thomas Gleixner <tglx.DeleteThis@linutronix.de>
Cc: Jeff Dike <jdike.DeleteThis@addtoit.com>
---
arch/um/drivers/mmapper_kern.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)
Index: linux-2.6-tip/arch/um/drivers/mmapper_kern.c
===================================================================
--- linux-2.6-tip.orig/arch/um/drivers/mmapper_kern.c
+++ linux-2.6-tip/arch/um/drivers/mmapper_kern.c
@@ -16,7 +16,7 @@
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/mm.h>
-#include <linux/smp_lock.h>
+
#include <asm/uaccess.h>
#include "mem_user.h"
@@ -78,7 +78,6 @@ out:
static int mmapper_open(struct inode *inode, struct file *file)
{
- cycle_kernel_lock();
return 0;
}
@@ -115,18 +114,16 @@ static int __init mmapper_init(void)
v_buf = (char *) find_iomem("mmapper", &mmapper_size);
if (mmapper_size == 0) {
printk(KERN_ERR "mmapper_init - find_iomem failed\n");
- goto out;
+ return -ENODEV;
}
+ p_buf = __pa(v_buf);
err = misc_register(&mmapper_dev);
if (err) {
printk(KERN_ERR "mmapper - misc_register failed, err = %d\n",
err);
- goto out;
+ return err;;
}
-
- p_buf = __pa(v_buf);
-out:
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 09/28] sys: Remove BKL from sys_reboot [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Serialization of sys_reboot can be done local. The BKL is not
protecting anything else.
Signed-off-by: Thomas Gleixner <tglx.DeleteThis@linutronix.de>
---
kernel/sys.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
Index: linux-2.6-tip/kernel/sys.c
===================================================================
--- linux-2.6-tip.orig/kernel/sys.c
+++ linux-2.6-tip/kernel/sys.c
@@ -8,7 +8,6 @@
#include <linux/mm.h>
#include <linux/utsname.h>
#include <linux/mman.h>
-#include <linux/smp_lock.h>
#include <linux/notifier.h>
#include <linux/reboot.h>
#include <linux/prctl.h>
@@ -349,6 +348,9 @@ void kernel_power_off(void)
machine_power_off();
}
EXPORT_SYMBOL_GPL(kernel_power_off);
+
+static DEFINE_MUTEX(reboot_mutex);
+
/*
* Reboot system call: for obvious reasons only root may call it,
* and even root needs to set up some magic numbers in the registers
@@ -381,7 +383,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
if ((cmd == LINUX_REBOOT_CMD_POWER_OFF) && !pm_power_off)
cmd = LINUX_REBOOT_CMD_HALT;
- lock_kernel();
+ mutex_lock(&reboot_mutex);
switch (cmd) {
case LINUX_REBOOT_CMD_RESTART:
kernel_restart(NULL);
@@ -397,20 +399,18 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
case LINUX_REBOOT_CMD_HALT:
kernel_halt();
- unlock_kernel();
do_exit(0);
panic("cannot halt");
case LINUX_REBOOT_CMD_POWER_OFF:
kernel_power_off();
- unlock_kernel();
do_exit(0);
break;
case LINUX_REBOOT_CMD_RESTART2:
if (strncpy_from_user(&buffer[0], arg, sizeof(buffer) - 1) < 0) {
- unlock_kernel();
- return -EFAULT;
+ ret = -EFAULT;
+ break;
}
buffer[sizeof(buffer) - 1] = '\0';
@@ -433,7 +433,7 @@ SYSCALL_DEFINE4(reboot, int, magic1, int
ret = -EINVAL;
break;
}
- unlock_kernel();
+ mutex_unlock(&reboot_mutex);
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 27/28] drivers: Remove BKL from scx200_gpio [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_kernel_lock() was added during the big BKL pushdown. It should
ensure the serializiation against driver init code. In this case there
is nothing to serialize. Remove it.
Signed-off-by: Thomas Gleixner <tglx RemoveThis @linutronix.de>
Cc: Jim Cromie <jim.cromie RemoveThis @gmail.com>
---
drivers/char/scx200_gpio.c | 2 --
1 file changed, 2 deletions(-)
Index: linux-2.6-tip/drivers/char/scx200_gpio.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/scx200_gpio.c
+++ linux-2.6-tip/drivers/char/scx200_gpio.c
@@ -12,7 +12,6 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/platform_device.h>
-#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -52,7 +51,6 @@ static int scx200_gpio_open(struct inode
unsigned m = iminor(inode);
file->private_data = &scx200_gpio_ops;
- cycle_kernel_lock();
if (m >= MAX_PINS)
return -EINVAL;
return nonseekable_open(inode, file);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 02/28] pm_qos: clean up racy global "name" variable [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
"name" is a poor name for a file-global variable. It was used in three
different functions, with no mutual exclusion. But it's just a tiny,
temporary string; let's just move it onto the stack in the functions that
need it. Also use snprintf() just in case.
Signed-off-by: Jonathan Corbet <corbet DeleteThis @lwn.net>
Cc: Mark Gross <mgross DeleteThis @linux.intel.com>
Reviewed-by: Frederic Weisbecker <fweisbec DeleteThis @gmail.com>
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
diff --git a/kernel/pm_qos_params.c b/kernel/pm_qos_params.c
index d96b83e..3db49b9 100644
--- a/kernel/pm_qos_params.c
+++ b/kernel/pm_qos_params.c
@@ -343,18 +343,18 @@ int pm_qos_remove_notifier(int pm_qos_class, struct notifier_block *notifier)
}
EXPORT_SYMBOL_GPL(pm_qos_remove_notifier);
-#define PID_NAME_LEN sizeof("process_1234567890")
-static char name[PID_NAME_LEN];
+#define PID_NAME_LEN 32
static int pm_qos_power_open(struct inode *inode, struct file *filp)
{
int ret;
long pm_qos_class;
+ char name[PID_NAME_LEN];
pm_qos_class = find_pm_qos_object_by_minor(iminor(inode));
if (pm_qos_class >= 0) {
filp->private_data = (void *)pm_qos_class;
- sprintf(name, "process_%d", current->pid);
+ snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
ret = pm_qos_add_requirement(pm_qos_class, name,
PM_QOS_DEFAULT_VALUE);
if (ret >= 0)
@@ -366,9 +366,10 @@ static int pm_qos_power_open(struct inode *inode, struct file *filp)
static int pm_qos_power_release(struct inode *inode, struct file *filp)
{
int pm_qos_class;
+ char name[PID_NAME_LEN];
pm_qos_class = (long)filp->private_data;
- sprintf(name, "process_%d", current->pid);
+ snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
pm_qos_remove_requirement(pm_qos_class, name);
return 0;
@@ -379,13 +380,14 @@ static ssize_t pm_qos_power_write(struct file *filp, const char __user *buf,
{
s32 value;
int pm_qos_class;
+ char name[PID_NAME_LEN];
pm_qos_class = (long)filp->private_data;
if (count != sizeof(s32))
return -EINVAL;
if (copy_from_user(&value, buf, sizeof(s32)))
return -EFAULT;
- sprintf(name, "process_%d", current->pid);
+ snprintf(name, PID_NAME_LEN, "process_%d", current->pid);
pm_qos_update_requirement(pm_qos_class, name, value);
return sizeof(s32);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 24/28] rtc: Remove BKL from efirtc [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
BKL locking came to efirtc via the big BKL push down, but the access
to the efi functions is protected by efi_rtc_lock already.
Remove it.
Signed-off-by: Thomas Gleixner <tglx.RemoveThis@linutronix.de>
---
drivers/char/efirtc.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
---
drivers/char/efirtc.c | 12 +-----------
1 file changed, 1 insertion(+), 11 deletions(-)
Index: linux-2.6-tip/drivers/char/efirtc.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/efirtc.c
+++ linux-2.6-tip/drivers/char/efirtc.c
@@ -27,8 +27,6 @@
* - Add module support
*/
-
-#include <linux/smp_lock.h>
#include <linux/types.h>
#include <linux/errno.h>
#include <linux/miscdevice.h>
@@ -174,13 +172,12 @@ static long efi_rtc_ioctl(struct file *f
return -EINVAL;
case RTC_RD_TIME:
- lock_kernel();
spin_lock_irqsave(&efi_rtc_lock, flags);
status = efi.get_time(&eft, &cap);
spin_unlock_irqrestore(&efi_rtc_lock,flags);
- unlock_kernel();
+
if (status != EFI_SUCCESS) {
/* should never happen */
printk(KERN_ERR "efitime: can't read time\n");
@@ -202,13 +199,11 @@ static long efi_rtc_ioctl(struct file *f
convert_to_efi_time(&wtime, &eft);
- lock_kernel();
spin_lock_irqsave(&efi_rtc_lock, flags);
status = efi.set_time(&eft);
spin_unlock_irqrestore(&efi_rtc_lock,flags);
- unlock_kernel();
return status == EFI_SUCCESS ? 0 : -EINVAL;
@@ -224,7 +219,6 @@ static long efi_rtc_ioctl(struct file *f
convert_to_efi_time(&wtime, &eft);
- lock_kernel();
spin_lock_irqsave(&efi_rtc_lock, flags);
/*
* XXX Fixme:
@@ -235,19 +229,16 @@ static long efi_rtc_ioctl(struct file *f
status = efi.set_wakeup_time((efi_bool_t)enabled, &eft);
spin_unlock_irqrestore(&efi_rtc_lock,flags);
- unlock_kernel();
return status == EFI_SUCCESS ? 0 : -EINVAL;
case RTC_WKALM_RD:
- lock_kernel();
spin_lock_irqsave(&efi_rtc_lock, flags);
status = efi.get_wakeup_time((efi_bool_t *)&enabled, (efi_bool_t *)&pending, &eft);
spin_unlock_irqrestore(&efi_rtc_lock,flags);
- unlock_kernel();
if (status != EFI_SUCCESS) return -EINVAL;
@@ -277,7 +268,6 @@ static int efi_rtc_open(struct inode *in
* We do accept multiple open files at the same time as we
* synchronize on the per call operation.
*/
- cycle_kernel_lock();
return 0;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 10/28] mem_class: Drop the bkl from memory_open() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
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.RemoveThis@gmail.com>
Cc: John Kacur <jkacur.RemoveThis@redhat.com>
Cc: Sven-Thorsten Dietrich <sven.RemoveThis@thebigcorporation.com>
Cc: Jonathan Corbet <corbet.RemoveThis@lwn.net>
Cc: Alessio Igor Bogani <abogani.RemoveThis@texware.it>
Cc: Greg Kroah-Hartman <gregkh.RemoveThis@suse.de>
LKML-Reference: <1255113062-5835-1-git-send-email-fweisbec.RemoveThis@gmail.com>
Signed-off-by: Thomas Gleixner <tglx.RemoveThis@linutronix.de>
---
drivers/char/mem.c | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
Index: linux-2.6-tip/drivers/char/mem.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/mem.c
+++ linux-2.6-tip/drivers/char/mem.c
@@ -26,7 +26,6 @@
#include <linux/bootmem.h>
#include <linux/splice.h>
#include <linux/pfn.h>
-#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -892,29 +891,23 @@ static int memory_open(struct inode *ino
{
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 = {
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.RemoveThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 18/28] watchdog: Remove BKL from rio watchdog driver [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_kernel_lock() was added with the BKL pushdown. The rio driver
indeed needs that because riowd_device is initialized after
misc_register(). So an open(), write/ioctl() which happens to get
between misc_register returning and riowd_device initialization would
dereference a NULL pointer.
Move riowd_device initialization before misc_register() and get rid of
cycle_kernel_lock().
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
Cc: David S. Miller <davem DeleteThis @davemloft.net>
---
drivers/watchdog/riowd.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
Index: linux-2.6-tip/drivers/watchdog/riowd.c
===================================================================
--- linux-2.6-tip.orig/drivers/watchdog/riowd.c
+++ linux-2.6-tip/drivers/watchdog/riowd.c
@@ -10,7 +10,6 @@
#include <linux/errno.h>
#include <linux/init.h>
#include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
#include <linux/watchdog.h>
#include <linux/of.h>
#include <linux/of_device.h>
@@ -75,7 +74,6 @@ static void riowd_writereg(struct riowd
static int riowd_open(struct inode *inode, struct file *filp)
{
- cycle_kernel_lock();
nonseekable_open(inode, filp);
return 0;
}
@@ -194,6 +192,8 @@ static int __devinit riowd_probe(struct
printk(KERN_ERR PFX "Cannot map registers.\n");
goto out_free;
}
+ /* Make miscdev useable right away */
+ riowd_device = p;
err = misc_register(&riowd_miscdev);
if (err) {
@@ -205,10 +205,10 @@ static int __devinit riowd_probe(struct
"regs at %p\n", riowd_timeout, p->regs);
dev_set_drvdata(&op->dev, p);
- riowd_device = p;
return 0;
out_iounmap:
+ riowd_device = NULL;
of_iounmap(&op->resource[0], p->regs, 2);
out_free:
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 04/28] x86: Remove BKL from microcode [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_lock_kernel() in microcode_open() is a worthless exercise as
there is nothing to wait for. Remove it.
Signed-off-by: Thomas Gleixner <tglx RemoveThis @linutronix.de>
---
arch/x86/kernel/microcode_core.c | 2 --
1 file changed, 2 deletions(-)
Index: linux-2.6-tip/arch/x86/kernel/microcode_core.c
===================================================================
--- linux-2.6-tip.orig/arch/x86/kernel/microcode_core.c
+++ linux-2.6-tip/arch/x86/kernel/microcode_core.c
@@ -73,7 +73,6 @@
#include <linux/platform_device.h>
#include <linux/miscdevice.h>
#include <linux/capability.h>
-#include <linux/smp_lock.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mutex.h>
@@ -201,7 +200,6 @@ static int do_microcode_update(const voi
static int microcode_open(struct inode *unused1, struct file *unused2)
{
- cycle_kernel_lock();
return capable(CAP_SYS_RAWIO) ? 0 : -EPERM;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 06/28] drivers: Remove BKL from cs5535_gpio [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
The big BKL pushdown added cycle_kernel_lock(). There is nothing to
wait for in this driver. Remove it.
Signed-off-by: Thomas Gleixner <tglx.TakeThisOut@linutronix.de>
---
drivers/char/cs5535_gpio.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
Index: linux-2.6-tip/drivers/char/cs5535_gpio.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/cs5535_gpio.c
+++ linux-2.6-tip/drivers/char/cs5535_gpio.c
@@ -17,7 +17,7 @@
#include <linux/cdev.h>
#include <linux/ioport.h>
#include <linux/pci.h>
-#include <linux/smp_lock.h>
+
#include <asm/uaccess.h>
#include <asm/io.h>
@@ -158,7 +158,6 @@ static int cs5535_gpio_open(struct inode
{
u32 m = iminor(inode);
- cycle_kernel_lock();
/* the mask says which pins are usable by this driver */
if ((mask & (1 << m)) == 0)
return -EINVAL;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.TakeThisOut@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 07/28] spi: Remove BKL from spidev_open [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
The BKL was added there with the big pushdown. Remove it as the code
is serialized already.
Signed-off-by: Thomas Gleixner <tglx.DeleteThis@linutronix.de>
Cc: David Brownell <dbrownell.DeleteThis@users.sourceforge.net>
---
drivers/spi/spidev.c | 3 ---
1 file changed, 3 deletions(-)
Index: linux-2.6-tip/drivers/spi/spidev.c
===================================================================
--- linux-2.6-tip.orig/drivers/spi/spidev.c
+++ linux-2.6-tip/drivers/spi/spidev.c
@@ -30,7 +30,6 @@
#include <linux/errno.h>
#include <linux/mutex.h>
#include <linux/slab.h>
-#include <linux/smp_lock.h>
#include <linux/spi/spi.h>
#include <linux/spi/spidev.h>
@@ -477,7 +476,6 @@ static int spidev_open(struct inode *ino
struct spidev_data *spidev;
int status = -ENXIO;
- lock_kernel();
mutex_lock(&device_list_lock);
list_for_each_entry(spidev, &device_list, device_entry) {
@@ -503,7 +501,6 @@ static int spidev_open(struct inode *ino
pr_debug("spidev: nothing for minor %d\n", iminor(inode));
mutex_unlock(&device_list_lock);
- unlock_kernel();
return status;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo.DeleteThis@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 11/28] nvram: Drop the bkl from nvram_llseek() [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
There is nothing to protect inside nvram_llseek(), the file
offset doesn't need to be protected and nvram_len is only
initialized from an __init path.
It's safe to remove the big kernel lock there.
Signed-off-by: Frederic Weisbecker <fweisbec DeleteThis @gmail.com>
Cc: John Kacur <jkacur DeleteThis @redhat.com>
Cc: Sven-Thorsten Dietrich <sven DeleteThis @thebigcorporation.com>
Cc: Jonathan Corbet <corbet DeleteThis @lwn.net>
Cc: Alessio Igor Bogani <abogani DeleteThis @texware.it>
Cc: Benjamin Herrenschmidt <benh DeleteThis @kernel.crashing.org>
Cc: Greg KH <gregkh DeleteThis @suse.de>
LKML-Reference: <1255116030-6929-1-git-send-email-fweisbec DeleteThis @gmail.com>
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
---
drivers/char/generic_nvram.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
Index: linux-2.6-tip/drivers/char/generic_nvram.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/generic_nvram.c
+++ linux-2.6-tip/drivers/char/generic_nvram.c
@@ -19,7 +19,6 @@
#include <linux/miscdevice.h>
#include <linux/fcntl.h>
#include <linux/init.h>
-#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#include <asm/nvram.h>
#ifdef CONFIG_PPC_PMAC
@@ -32,7 +31,6 @@ static ssize_t nvram_len;
static loff_t nvram_llseek(struct file *file, loff_t offset, int origin)
{
- lock_kernel();
switch (origin) {
case 1:
offset += file->f_pos;
@@ -41,12 +39,11 @@ static loff_t nvram_llseek(struct file *
offset += nvram_len;
break;
}
- if (offset < 0) {
- unlock_kernel();
+ if (offset < 0)
return -EINVAL;
- }
+
file->f_pos = offset;
- unlock_kernel();
+
return file->f_pos;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 26/28] drivers: Remove BKL from pc8736x_gpio [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
cycle_kernel_lock() was added during the big BKL pushdown. It should
ensure the serializiation against driver init code. In this case there
is nothing to serialize. Remove it.
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
Cc: Jim Cromie <jim.cromie DeleteThis @gmail.com>
---
drivers/char/pc8736x_gpio.c | 2 --
1 file changed, 2 deletions(-)
Index: linux-2.6-tip/drivers/char/pc8736x_gpio.c
===================================================================
--- linux-2.6-tip.orig/drivers/char/pc8736x_gpio.c
+++ linux-2.6-tip/drivers/char/pc8736x_gpio.c
@@ -20,7 +20,6 @@
#include <linux/mutex.h>
#include <linux/nsc_gpio.h>
#include <linux/platform_device.h>
-#include <linux/smp_lock.h>
#include <asm/uaccess.h>
#define DEVNAME "pc8736x_gpio"
@@ -223,7 +222,6 @@ static int pc8736x_gpio_open(struct inod
unsigned m = iminor(inode);
file->private_data = &pc8736x_gpio_ops;
- cycle_kernel_lock();
dev_dbg(&pdev->dev, "open %d\n", m);
if (m >= PC8736X_GPIO_CT)
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 03/28] net: Remove BKL from tun [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
The lock_kernel/unlock_kernel() in cycle_kernel_lock() which is called
in tun_chr_open() is not serializing against anything and safe to
remove.
tun_chr_fasync() is serialized by get/put_tun() and fasync_helper()
has no dependency on BKL. The modification of tun->flags is racy with
and without the BKL so removing it does not make it worse.
Signed-off-by: Thomas Gleixner <tglx RemoveThis @linutronix.de>
Cc: Herbert Xu <herbert RemoveThis @gondor.apana.org.au>
Cc: David S. Miller <davem RemoveThis @davemloft.net>
---
drivers/net/tun.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
Index: linux-2.6-tip/drivers/net/tun.c
===================================================================
--- linux-2.6-tip.orig/drivers/net/tun.c
+++ linux-2.6-tip/drivers/net/tun.c
@@ -44,7 +44,6 @@
#include <linux/kernel.h>
#include <linux/major.h>
#include <linux/slab.h>
-#include <linux/smp_lock.h>
#include <linux/poll.h>
#include <linux/fcntl.h>
#include <linux/init.h>
@@ -1285,7 +1284,6 @@ static int tun_chr_fasync(int fd, struct
DBG(KERN_INFO "%s: tun_chr_fasync %d\n", tun->dev->name, on);
- lock_kernel();
if ((ret = fasync_helper(fd, file, on, &tun->fasync)) < 0)
goto out;
@@ -1298,7 +1296,6 @@ static int tun_chr_fasync(int fd, struct
tun->flags &= ~TUN_FASYNC;
ret = 0;
out:
- unlock_kernel();
tun_put(tun);
return ret;
}
@@ -1306,7 +1303,7 @@ out:
static int tun_chr_open(struct inode *inode, struct file * file)
{
struct tun_file *tfile;
- cycle_kernel_lock();
+
DBG1(KERN_INFO "tunX: tun_chr_open\n");
tfile = kmalloc(sizeof(*tfile), GFP_KERNEL);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo RemoveThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
Thomas Gleixner External

Since: May 14, 2006 Posts: 944
|
Posted: Sat Oct 10, 2009 12:10 pm Post subject: [patch 25/28] parisc: Remove BKL from eisa_eeprom [Login to view extended thread Info.] Archived from groups: per prev. post (more info?) |
|
|
Remove the empty ioctl and the cycle_kernel_lock() in
eisa_eeprom_open() which got there with the big BKL push down. There
is nothing to wait for and sychronize with after the misc device has
been registered.
Signed-off-by: Thomas Gleixner <tglx DeleteThis @linutronix.de>
Cc: Kyle McMartin <kyle DeleteThis @parisc-linux.org>
---
drivers/parisc/eisa_eeprom.c | 10 ----------
1 file changed, 10 deletions(-)
Index: linux-2.6-tip/drivers/parisc/eisa_eeprom.c
===================================================================
--- linux-2.6-tip.orig/drivers/parisc/eisa_eeprom.c
+++ linux-2.6-tip/drivers/parisc/eisa_eeprom.c
@@ -75,17 +75,8 @@ static ssize_t eisa_eeprom_read(struct f
return ret;
}
-static int eisa_eeprom_ioctl(struct inode *inode, struct file *file,
- unsigned int cmd,
- unsigned long arg)
-{
- return -ENOTTY;
-}
-
static int eisa_eeprom_open(struct inode *inode, struct file *file)
{
- cycle_kernel_lock();
-
if (file->f_mode & FMODE_WRITE)
return -EINVAL;
@@ -104,7 +95,6 @@ static const struct file_operations eisa
.owner = THIS_MODULE,
.llseek = eisa_eeprom_llseek,
.read = eisa_eeprom_read,
- .ioctl = eisa_eeprom_ioctl,
.open = eisa_eeprom_open,
.release = eisa_eeprom_release,
};
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo DeleteThis @vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/ |
|
| Back to top |
|
 |
|
|
|
You can post new topics in this forum You can reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
| |
|
|