Commit 9a181c58617134822ae596339dbea076ef9b5cf7
1 parent
fa0d4c26be
Exists in
master
and in
7 other branches
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: Arnd Bergmann <arnd@arndb.de> Cc: Jeff Dike <jdike@addtoit.com> Cc: user-mode-linux-devel@lists.sourceforge.net
Showing 4 changed files with 20 additions and 18 deletions Side-by-side Diff
arch/um/drivers/harddog_kern.c
... | ... | @@ -42,7 +42,7 @@ |
42 | 42 | #include <linux/miscdevice.h> |
43 | 43 | #include <linux/watchdog.h> |
44 | 44 | #include <linux/reboot.h> |
45 | -#include <linux/smp_lock.h> | |
45 | +#include <linux/mutex.h> | |
46 | 46 | #include <linux/init.h> |
47 | 47 | #include <linux/spinlock.h> |
48 | 48 | #include <asm/uaccess.h> |
... | ... | @@ -50,6 +50,7 @@ |
50 | 50 | |
51 | 51 | MODULE_LICENSE("GPL"); |
52 | 52 | |
53 | +static DEFINE_MUTEX(harddog_mutex); | |
53 | 54 | static DEFINE_SPINLOCK(lock); |
54 | 55 | static int timer_alive; |
55 | 56 | static int harddog_in_fd = -1; |
... | ... | @@ -66,7 +67,7 @@ |
66 | 67 | int err = -EBUSY; |
67 | 68 | char *sock = NULL; |
68 | 69 | |
69 | - lock_kernel(); | |
70 | + mutex_lock(&harddog_mutex); | |
70 | 71 | spin_lock(&lock); |
71 | 72 | if(timer_alive) |
72 | 73 | goto err; |
73 | 74 | |
... | ... | @@ -83,11 +84,11 @@ |
83 | 84 | |
84 | 85 | timer_alive = 1; |
85 | 86 | spin_unlock(&lock); |
86 | - unlock_kernel(); | |
87 | + mutex_unlock(&harddog_mutex); | |
87 | 88 | return nonseekable_open(inode, file); |
88 | 89 | err: |
89 | 90 | spin_unlock(&lock); |
90 | - unlock_kernel(); | |
91 | + mutex_unlock(&harddog_mutex); | |
91 | 92 | return err; |
92 | 93 | } |
93 | 94 | |
94 | 95 | |
... | ... | @@ -153,9 +154,9 @@ |
153 | 154 | { |
154 | 155 | long ret; |
155 | 156 | |
156 | - lock_kernel(); | |
157 | + mutex_lock(&harddog_mutex); | |
157 | 158 | ret = harddog_ioctl_unlocked(file, cmd, arg); |
158 | - unlock_kernel(); | |
159 | + mutex_unlock(&harddog_mutex); | |
159 | 160 | |
160 | 161 | return ret; |
161 | 162 | } |
arch/um/drivers/hostaudio_kern.c
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | #include "linux/slab.h" |
9 | 9 | #include "linux/sound.h" |
10 | 10 | #include "linux/soundcard.h" |
11 | -#include "linux/smp_lock.h" | |
11 | +#include "linux/mutex.h" | |
12 | 12 | #include "asm/uaccess.h" |
13 | 13 | #include "init.h" |
14 | 14 | #include "os.h" |
... | ... | @@ -67,6 +67,8 @@ |
67 | 67 | |
68 | 68 | #endif |
69 | 69 | |
70 | +static DEFINE_MUTEX(hostaudio_mutex); | |
71 | + | |
70 | 72 | /* /dev/dsp file operations */ |
71 | 73 | |
72 | 74 | static ssize_t hostaudio_read(struct file *file, char __user *buffer, |
73 | 75 | |
... | ... | @@ -202,9 +204,9 @@ |
202 | 204 | w = 1; |
203 | 205 | |
204 | 206 | kparam_block_sysfs_write(dsp); |
205 | - lock_kernel(); | |
207 | + mutex_lock(&hostaudio_mutex); | |
206 | 208 | ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0); |
207 | - unlock_kernel(); | |
209 | + mutex_unlock(&hostaudio_mutex); | |
208 | 210 | kparam_unblock_sysfs_write(dsp); |
209 | 211 | |
210 | 212 | if (ret < 0) { |
211 | 213 | |
... | ... | @@ -263,9 +265,9 @@ |
263 | 265 | w = 1; |
264 | 266 | |
265 | 267 | kparam_block_sysfs_write(mixer); |
266 | - lock_kernel(); | |
268 | + mutex_lock(&hostaudio_mutex); | |
267 | 269 | ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0); |
268 | - unlock_kernel(); | |
270 | + mutex_unlock(&hostaudio_mutex); | |
269 | 271 | kparam_unblock_sysfs_write(mixer); |
270 | 272 | |
271 | 273 | if (ret < 0) { |
arch/um/drivers/ubd_kern.c
... | ... | @@ -33,7 +33,7 @@ |
33 | 33 | #include "linux/mm.h" |
34 | 34 | #include "linux/slab.h" |
35 | 35 | #include "linux/vmalloc.h" |
36 | -#include "linux/smp_lock.h" | |
36 | +#include "linux/mutex.h" | |
37 | 37 | #include "linux/blkpg.h" |
38 | 38 | #include "linux/genhd.h" |
39 | 39 | #include "linux/spinlock.h" |
... | ... | @@ -100,6 +100,7 @@ |
100 | 100 | #define DRIVER_NAME "uml-blkdev" |
101 | 101 | |
102 | 102 | static DEFINE_MUTEX(ubd_lock); |
103 | +static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */ | |
103 | 104 | |
104 | 105 | static int ubd_open(struct block_device *bdev, fmode_t mode); |
105 | 106 | static int ubd_release(struct gendisk *disk, fmode_t mode); |
... | ... | @@ -1099,7 +1100,7 @@ |
1099 | 1100 | struct ubd *ubd_dev = disk->private_data; |
1100 | 1101 | int err = 0; |
1101 | 1102 | |
1102 | - lock_kernel(); | |
1103 | + mutex_lock(&ubd_mutex); | |
1103 | 1104 | if(ubd_dev->count == 0){ |
1104 | 1105 | err = ubd_open_dev(ubd_dev); |
1105 | 1106 | if(err){ |
... | ... | @@ -1118,7 +1119,7 @@ |
1118 | 1119 | err = -EROFS; |
1119 | 1120 | }*/ |
1120 | 1121 | out: |
1121 | - unlock_kernel(); | |
1122 | + mutex_unlock(&ubd_mutex); | |
1122 | 1123 | return err; |
1123 | 1124 | } |
1124 | 1125 | |
1125 | 1126 | |
... | ... | @@ -1126,10 +1127,10 @@ |
1126 | 1127 | { |
1127 | 1128 | struct ubd *ubd_dev = disk->private_data; |
1128 | 1129 | |
1129 | - lock_kernel(); | |
1130 | + mutex_lock(&ubd_mutex); | |
1130 | 1131 | if(--ubd_dev->count == 0) |
1131 | 1132 | ubd_close_dev(ubd_dev); |
1132 | - unlock_kernel(); | |
1133 | + mutex_unlock(&ubd_mutex); | |
1133 | 1134 | return 0; |
1134 | 1135 | } |
1135 | 1136 |
arch/um/kernel/exec.c
... | ... | @@ -78,14 +78,12 @@ |
78 | 78 | long error; |
79 | 79 | char *filename; |
80 | 80 | |
81 | - lock_kernel(); | |
82 | 81 | filename = getname(file); |
83 | 82 | error = PTR_ERR(filename); |
84 | 83 | if (IS_ERR(filename)) goto out; |
85 | 84 | error = execve1(filename, argv, env); |
86 | 85 | putname(filename); |
87 | 86 | out: |
88 | - unlock_kernel(); | |
89 | 87 | return error; |
90 | 88 | } |