Commit 9a181c58 authored by Arnd Bergmann's avatar Arnd Bergmann

uml: kill big kernel lock

Three uml device drivers still use the big kernel lock,
but all of them can be safely converted to using
a per-driver mutex instead. Most likely this is not
even necessary, so after further review these can
and should be removed as well.

The exec system call no longer requires the BKL either,
so remove it from there, too.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Cc: Jeff Dike <jdike@addtoit.com>
Cc: user-mode-linux-devel@lists.sourceforge.net
parent fa0d4c26
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
#include <linux/miscdevice.h> #include <linux/miscdevice.h>
#include <linux/watchdog.h> #include <linux/watchdog.h>
#include <linux/reboot.h> #include <linux/reboot.h>
#include <linux/smp_lock.h> #include <linux/mutex.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
static DEFINE_MUTEX(harddog_mutex);
static DEFINE_SPINLOCK(lock); static DEFINE_SPINLOCK(lock);
static int timer_alive; static int timer_alive;
static int harddog_in_fd = -1; static int harddog_in_fd = -1;
...@@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file) ...@@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file)
int err = -EBUSY; int err = -EBUSY;
char *sock = NULL; char *sock = NULL;
lock_kernel(); mutex_lock(&harddog_mutex);
spin_lock(&lock); spin_lock(&lock);
if(timer_alive) if(timer_alive)
goto err; goto err;
...@@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file) ...@@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file)
timer_alive = 1; timer_alive = 1;
spin_unlock(&lock); spin_unlock(&lock);
unlock_kernel(); mutex_unlock(&harddog_mutex);
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
err: err:
spin_unlock(&lock); spin_unlock(&lock);
unlock_kernel(); mutex_unlock(&harddog_mutex);
return err; return err;
} }
...@@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file, ...@@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file,
{ {
long ret; long ret;
lock_kernel(); mutex_lock(&harddog_mutex);
ret = harddog_ioctl_unlocked(file, cmd, arg); ret = harddog_ioctl_unlocked(file, cmd, arg);
unlock_kernel(); mutex_unlock(&harddog_mutex);
return ret; return ret;
} }
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "linux/slab.h" #include "linux/slab.h"
#include "linux/sound.h" #include "linux/sound.h"
#include "linux/soundcard.h" #include "linux/soundcard.h"
#include "linux/smp_lock.h" #include "linux/mutex.h"
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "init.h" #include "init.h"
#include "os.h" #include "os.h"
...@@ -67,6 +67,8 @@ MODULE_PARM_DESC(mixer, MIXER_HELP); ...@@ -67,6 +67,8 @@ MODULE_PARM_DESC(mixer, MIXER_HELP);
#endif #endif
static DEFINE_MUTEX(hostaudio_mutex);
/* /dev/dsp file operations */ /* /dev/dsp file operations */
static ssize_t hostaudio_read(struct file *file, char __user *buffer, static ssize_t hostaudio_read(struct file *file, char __user *buffer,
...@@ -202,9 +204,9 @@ static int hostaudio_open(struct inode *inode, struct file *file) ...@@ -202,9 +204,9 @@ static int hostaudio_open(struct inode *inode, struct file *file)
w = 1; w = 1;
kparam_block_sysfs_write(dsp); kparam_block_sysfs_write(dsp);
lock_kernel(); mutex_lock(&hostaudio_mutex);
ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
unlock_kernel(); mutex_unlock(&hostaudio_mutex);
kparam_unblock_sysfs_write(dsp); kparam_unblock_sysfs_write(dsp);
if (ret < 0) { if (ret < 0) {
...@@ -263,9 +265,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file) ...@@ -263,9 +265,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
w = 1; w = 1;
kparam_block_sysfs_write(mixer); kparam_block_sysfs_write(mixer);
lock_kernel(); mutex_lock(&hostaudio_mutex);
ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
unlock_kernel(); mutex_unlock(&hostaudio_mutex);
kparam_unblock_sysfs_write(mixer); kparam_unblock_sysfs_write(mixer);
if (ret < 0) { if (ret < 0) {
......
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
#include "linux/mm.h" #include "linux/mm.h"
#include "linux/slab.h" #include "linux/slab.h"
#include "linux/vmalloc.h" #include "linux/vmalloc.h"
#include "linux/smp_lock.h" #include "linux/mutex.h"
#include "linux/blkpg.h" #include "linux/blkpg.h"
#include "linux/genhd.h" #include "linux/genhd.h"
#include "linux/spinlock.h" #include "linux/spinlock.h"
...@@ -100,6 +100,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data) ...@@ -100,6 +100,7 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)
#define DRIVER_NAME "uml-blkdev" #define DRIVER_NAME "uml-blkdev"
static DEFINE_MUTEX(ubd_lock); static DEFINE_MUTEX(ubd_lock);
static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */
static int ubd_open(struct block_device *bdev, fmode_t mode); static int ubd_open(struct block_device *bdev, fmode_t mode);
static int ubd_release(struct gendisk *disk, fmode_t mode); static int ubd_release(struct gendisk *disk, fmode_t mode);
...@@ -1099,7 +1100,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode) ...@@ -1099,7 +1100,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
struct ubd *ubd_dev = disk->private_data; struct ubd *ubd_dev = disk->private_data;
int err = 0; int err = 0;
lock_kernel(); mutex_lock(&ubd_mutex);
if(ubd_dev->count == 0){ if(ubd_dev->count == 0){
err = ubd_open_dev(ubd_dev); err = ubd_open_dev(ubd_dev);
if(err){ if(err){
...@@ -1118,7 +1119,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode) ...@@ -1118,7 +1119,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
err = -EROFS; err = -EROFS;
}*/ }*/
out: out:
unlock_kernel(); mutex_unlock(&ubd_mutex);
return err; return err;
} }
...@@ -1126,10 +1127,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode) ...@@ -1126,10 +1127,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode)
{ {
struct ubd *ubd_dev = disk->private_data; struct ubd *ubd_dev = disk->private_data;
lock_kernel(); mutex_lock(&ubd_mutex);
if(--ubd_dev->count == 0) if(--ubd_dev->count == 0)
ubd_close_dev(ubd_dev); ubd_close_dev(ubd_dev);
unlock_kernel(); mutex_unlock(&ubd_mutex);
return 0; return 0;
} }
......
...@@ -78,13 +78,11 @@ long sys_execve(const char __user *file, char __user *__user *argv, ...@@ -78,13 +78,11 @@ long sys_execve(const char __user *file, char __user *__user *argv,
long error; long error;
char *filename; char *filename;
lock_kernel();
filename = getname(file); filename = getname(file);
error = PTR_ERR(filename); error = PTR_ERR(filename);
if (IS_ERR(filename)) goto out; if (IS_ERR(filename)) goto out;
error = execve1(filename, argv, env); error = execve1(filename, argv, env);
putname(filename); putname(filename);
out: out:
unlock_kernel();
return error; return error;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment