Skip to content

Commit 205153a

Browse files
fweisbecKAGA-KOKO
authored andcommitted
mem_class: Drop the bkl from memory_open()
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> LKML-Reference: <1255113062-5835-1-git-send-email-fweisbec@gmail.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
1 parent 4c2aedc commit 205153a

1 file changed

Lines changed: 5 additions & 12 deletions

File tree

‎drivers/char/mem.c‎

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/bootmem.h>
2727
#include <linux/splice.h>
2828
#include <linux/pfn.h>
29-
#include <linux/smp_lock.h>
3029

3130
#include <asm/uaccess.h>
3231
#include <asm/io.h>
@@ -892,29 +891,23 @@ static int memory_open(struct inode *inode, struct file *filp)
892891
{
893892
int minor;
894893
const struct memdev *dev;
895-
int ret = -ENXIO;
896-
897-
lock_kernel();
898894

899895
minor = iminor(inode);
900896
if (minor >= ARRAY_SIZE(devlist))
901-
goto out;
897+
return -ENXIO;
902898

903899
dev = &devlist[minor];
904900
if (!dev->fops)
905-
goto out;
901+
return -ENXIO;
906902

907903
filp->f_op = dev->fops;
908904
if (dev->dev_info)
909905
filp->f_mapping->backing_dev_info = dev->dev_info;
910906

911907
if (dev->fops->open)
912-
ret = dev->fops->open(inode, filp);
913-
else
914-
ret = 0;
915-
out:
916-
unlock_kernel();
917-
return ret;
908+
return dev->fops->open(inode, filp);
909+
910+
return 0;
918911
}
919912

920913
static const struct file_operations memory_fops = {

0 commit comments

Comments
 (0)