Skip to contentSkip to conversation

Make the big kernel lock optional

PATCH Applied Arnd Bergmann 7 participants 19 messages Sep 14, 2010 – Oct 16, 2010

Subsystems (7)
lore
Share & tools
lore
#0 lore raw

cover Make the big kernel lock optional

This is a set of simple patches to remove the big kernel lock in some remaining areas and introduce a Kconfig option which I'd like to have included in linux-next and get included in the 2.6.37 merge window.

I have a total of five topic branches, which together remove the BKL from all code except those modules which get marked as 'depends on BKL' in the final patch of this series.

It's fine if maintainers want to add some of these patches to their own queue, as long as they all make it into linux-next.

Stephen, please add git+ssh://master.kernel.org/pub/scm/linux/kernel/git/arnd/bkl.git config

Arnd Bergmann (17):
hpet: kill BKL, add compat_ioctl
proc/pci: kill BKL
s390/block: kill the big kernel lock
isapnp: BKL removal
alpha: kill big kernel lock
cris: autoconvert trivial BKL users
m68k: remove big kernel lock
parisc: remove big kernel lock
sh: kill big kernel lock
uml: kill big kernel lock
tlclk: remove big kernel lock
i4l: kill big kernel lock
misdn: kill big kernel lock
dvb/bt8xx: kill the big kernel lock
dvb-core: kill the big kernel lock
rtmutex-tester: make it build without BKL
BKL: introduce CONFIG_BKL.

Al Viro (1):
fix rawctl compat ioctls breakage on amd64 and itanic

 arch/alpha/kernel/osf_sys.c                 |    5 -
 arch/alpha/kernel/traps.c                   |    3 -
 arch/cris/arch-v10/drivers/ds1302.c         |    7 +-
 arch/cris/arch-v10/drivers/pcf8563.c        |    6 +-
 arch/cris/arch-v10/drivers/sync_serial.c    |   11 +-
 arch/cris/arch-v32/drivers/cryptocop.c      |    4 +-
 arch/cris/arch-v32/drivers/mach-a3/gpio.c   |   11 +-
 arch/cris/arch-v32/drivers/mach-fs/gpio.c   |   11 +-
 arch/cris/arch-v32/drivers/pcf8563.c        |    6 +-
 arch/cris/arch-v32/drivers/sync_serial.c    |   11 +-
 arch/m68k/kernel/sys_m68k.c                 |    7 +-
 arch/parisc/kernel/perf.c                   |    4 -
 arch/sh/kernel/ptrace_64.c                  |    9 +-
 arch/um/drivers/harddog_kern.c              |   13 +-
 arch/um/drivers/hostaudio_kern.c            |    8 +-
 arch/um/drivers/ubd_kern.c                  |    8 +-
 arch/um/kernel/exec.c                       |    2 -
 drivers/char/hpet.c                         |   98 +++++++----
 drivers/char/raw.c                          |  243 +++++++++++++++-----------
 drivers/char/tlclk.c                        |    6 +-
 drivers/gpu/drm/Kconfig                     |    5 +-
 drivers/isdn/capi/Kconfig                   |    2 +-
 drivers/isdn/i4l/isdn_tty.c                 |   11 +-
 drivers/isdn/mISDN/stack.c                  |    7 -
 drivers/media/Kconfig                       |    1 +
 drivers/media/dvb/bt8xx/dst_ca.c            |    7 +-
 drivers/media/dvb/dvb-core/dmxdev.c         |   17 +--
 drivers/media/dvb/dvb-core/dvb_ca_en50221.c |    8 +-
 drivers/media/dvb/dvb-core/dvb_net.c        |    9 +-
 drivers/media/dvb/dvb-core/dvbdev.c         |   17 +-
 drivers/net/appletalk/Kconfig               |    1 +
 drivers/pci/proc.c                          |    4 +-
 drivers/pnp/isapnp/proc.c                   |   13 +-
 drivers/s390/block/dasd.c                   |    6 -
 drivers/s390/block/dasd_ioctl.c             |   17 +--
 drivers/s390/block/dcssblk.c                |    5 -
 drivers/staging/cx25821/Kconfig             |    1 +
 drivers/staging/easycap/Kconfig             |    1 +
 drivers/staging/go7007/Kconfig              |    1 +
 drivers/staging/usbip/Kconfig               |    2 +-
 drivers/usb/gadget/Kconfig                  |    2 +-
 fs/Kconfig                                  |    1 +
 fs/adfs/Kconfig                             |    1 +
 fs/afs/Kconfig                              |    1 +
 fs/autofs/Kconfig                           |    1 +
 fs/autofs4/Kconfig                          |    1 +
 fs/ceph/Kconfig                             |    1 +
 fs/coda/Kconfig                             |    1 +
 fs/compat_ioctl.c                           |   70 --------
 fs/ecryptfs/Kconfig                         |    1 +
 fs/freevxfs/Kconfig                         |    1 +
 fs/hpfs/Kconfig                             |    1 +
 fs/jffs2/Kconfig                            |    1 +
 fs/ncpfs/Kconfig                            |    1 +
 fs/nfs/Kconfig                              |    1 +
 fs/nfsd/Kconfig                             |    1 +
 fs/ocfs2/Kconfig                            |    1 +
 fs/qnx4/Kconfig                             |    1 +
 fs/reiserfs/Kconfig                         |    1 +
 fs/smbfs/Kconfig                            |    1 +
 fs/squashfs/Kconfig                         |    1 +
 fs/udf/Kconfig                              |    1 +
 fs/ufs/Kconfig                              |    1 +
 include/linux/smp_lock.h                    |    7 +-
 init/Kconfig                                |    2 +-
 kernel/rtmutex-tester.c                     |    6 +
 kernel/trace/Kconfig                        |    1 +
 lib/Kconfig.debug                           |    9 +
 net/ipx/Kconfig                             |    1 +
 net/irda/Kconfig                            |    1 +
 net/irda/irnet/Kconfig                      |    1 +
 net/x25/Kconfig                             |    1 +
 72 files changed, 355 insertions(+), 375 deletions(-)
Cc Al Viro <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Arjan van de Ven <[email protected]>
Cc Bob Picco <[email protected]>
Cc Clemens Ladisch <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Helge Deller <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Jeff Dike <[email protected]>
Cc Jesper Nilsson <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Karsten Keil <[email protected]>
Cc Kyle McMartin <[email protected]>
Cc Linus Torvalds <[email protected]>
Cc Mark Gross <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc Matt Turner <[email protected]>
Cc Mauro Carvalho Chehab <[email protected]>
Cc Mikael Starvik <[email protected]>
Cc Paul Mundt <[email protected]>
Cc Richard Henderson <[email protected]>
Cc Roman Zippel <[email protected]>
Cc Stephen Rothwell <[email protected]>
Cc Tejun Heo <[email protected]>
Cc Thomas Gleixner <[email protected]>

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev

#1 lore raw

PATCH 5/18 alpha: kill big kernel lock

All uses of the BKL on alpha are totally bogus, nothing is really protected by this. Remove the remaining users so we don't have to mark alpha as 'depends on BKL'.

Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>
---
 arch/alpha/kernel/osf_sys.c |    5 -----
 arch/alpha/kernel/traps.c   |    3 ---
 2 files changed, 0 insertions(+), 8 deletions(-)
arch/alpha/kernel/osf_sys.c +0 -5
index 5d1e6d6..49225dd 100644
@@ -15,7 +15,6 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
 #include <linux/stddef.h>
 #include <linux/syscalls.h>
 #include <linux/unistd.h>
@@ -69,7 +68,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
 {
 	struct mm_struct *mm;
 
-	lock_kernel();
 	mm = current->mm;
 	mm->end_code = bss_start + bss_len;
 	mm->start_brk = bss_start + bss_len;
@@ -78,7 +76,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
 	printk("set_program_attributes(%lx %lx %lx %lx)\n",
 		text_start, text_len, bss_start, bss_len);
 #endif
-	unlock_kernel();
 	return 0;
 }
 
@@ -517,7 +514,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
 	long error;
 	int __user *min_buf_size_ptr;
 
-	lock_kernel();
 	switch (code) {
 	case PL_SET:
 		if (get_user(error, &args->set.nbytes))
@@ -547,7 +543,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
 		error = -EOPNOTSUPP;
 		break;
 	};
-	unlock_kernel();
 	return error;
 }
 
arch/alpha/kernel/traps.c +0 -3
index b14f015..0414e02 100644
@@ -13,7 +13,6 @@
 #include <linux/sched.h>
 #include <linux/tty.h>
 #include <linux/delay.h>
-#include <linux/smp_lock.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kallsyms.h>
@@ -623,7 +622,6 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg,
 		return;
 	}
 
-	lock_kernel();
 	printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n",
 		pc, va, opcode, reg);
 	do_exit(SIGSEGV);
@@ -646,7 +644,6 @@ got_exception:
 	 * Yikes!  No one to forward the exception to.
 	 * Since the registers are in a weird format, dump them ourselves.
  	 */
-	lock_kernel();
 
 	printk("%s(%d): unhandled unaligned exception\n",
 	       current->comm, task_pid_nr(current));
Signature · 1 line
1.7.1
maintainer
#2 lore raw

Re: [PATCH 05/18] alpha: kill big kernel lock

Quoted 87 lines · Arnd Bergmann

All uses of the BKL on alpha are totally bogus, nothing is really protected by this. Remove the remaining users so we don't have to mark alpha as 'depends on BKL'.

Cc Richard Henderson <[email protected]>
Cc Ivan Kokshaysky <[email protected]>
Cc Matt Turner <[email protected]>

---
 arch/alpha/kernel/osf_sys.c |    5 -----
 arch/alpha/kernel/traps.c   |    3 ---

 2 files changed, 0 insertions(+), 8 deletions(-)
arch/alpha/kernel/osf_sys.c +0 -4
index 5d1e6d6..49225dd 100644
@@ -15,7 +15,6 @@
  #include <linux/kernel.h>
  #include <linux/mm.h>
  #include <linux/smp.h>
-#include <linux/smp_lock.h>
  #include <linux/stddef.h>
  #include <linux/syscalls.h>
  #include <linux/unistd.h>
@@ -69,7 +68,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
  {
        struct mm_struct *mm;
 
-       lock_kernel();
        mm = current->mm;
        mm->end_code = bss_start + bss_len;
        mm->start_brk = bss_start + bss_len;
@@ -78,7 +76,6 @@ SYSCALL_DEFINE4(osf_set_program_attributes, unsigned long, text_start,
        printk("set_program_attributes(%lx %lx %lx %lx)\n",
                text_start, text_len, bss_start, bss_len);
  #endif
-       unlock_kernel();
        return 0;
  }
 
@@ -517,7 +514,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
        long error;
        int __user *min_buf_size_ptr;
 
-       lock_kernel();
        switch (code) {

       case PL_SET:
               if (get_user(error, &args->set.nbytes))

arch/alpha/kernel/osf_sys.c +0 -1
@@ -547,7 +543,6 @@ SYSCALL_DEFINE2(osf_proplist_syscall, enum pl_code, code,
                error = -EOPNOTSUPP;
                break;
        };
-       unlock_kernel();
        return error;
  }
 
arch/alpha/kernel/traps.c +0 -4
index b14f015..0414e02 100644
@@ -13,7 +13,6 @@
  #include <linux/sched.h>
  #include <linux/tty.h>
  #include <linux/delay.h>
-#include <linux/smp_lock.h>
  #include <linux/module.h>
  #include <linux/init.h>
  #include <linux/kallsyms.h>
@@ -623,7 +622,6 @@ do_entUna(void * va, unsigned long opcode, unsigned long reg,
                return;
        }
 
-       lock_kernel();
        printk("Bad unaligned kernel access at %016lx: %p %lx %lu\n",
                pc, va, opcode, reg);
        do_exit(SIGSEGV);
@@ -646,7 +644,6 @@ got_exception:
         * Yikes!  No one to forward the exception to.
         * Since the registers are in a weird format, dump them ourselves.
         */
-       lock_kernel();
 
        printk("%s(%d): unhandled unaligned exception\n",
               current->comm, task_pid_nr(current));
--
Quoted 1 line

1.7.1

I can apply this without any other patches in the series, since the usage is bogus, right?

Thanks,
Matt
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#3 lore raw

Re: [PATCH 05/18] alpha: kill big kernel lock

Quoted 2 lines · On Tuesday 14 September 2010 21:41:01 Matt Turner wrote:

I can apply this without any other patches in the series, since the usage is bogus, right?

Yes, definitely.

Arnd

maintainer
#4 lore raw

Re: [PATCH 05/18] alpha: kill big kernel lock

Quoted 7 lines · Arnd Bergmann
Quoted 2 lines · On Tuesday 14 September 2010 21:41:01 Matt Turner wrote:

I can apply this without any other patches in the series, since the usage is bogus, right?

Yes, definitely.

       Arnd

Will do so then. Thanks for the patch!
--
To unsubscribe from this list: send the line "unsubscribe linux-alpha" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

PATCH 7/18 m68k: remove big kernel lock

In reply to Arnd Bergmann

The cache flush code only locks against itself, so there is no excuse to use the BKL here. This replaces it with a local mutex in order to maintain serialization of flushes.

Cc Geert Uytterhoeven <[email protected]>
Cc Roman Zippel <[email protected]>
---
 arch/m68k/kernel/sys_m68k.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
arch/m68k/kernel/sys_m68k.c +4 -3
index 2f431ec..f6aec52 100644
@@ -12,7 +12,7 @@
 #include <linux/mm.h>
 #include <linux/fs.h>
 #include <linux/smp.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/sem.h>
 #include <linux/msg.h>
 #include <linux/shm.h>
@@ -374,10 +374,11 @@ cache_flush_060 (unsigned long addr, int scope, int cache, unsigned long len)
 asmlinkage int
 sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
 {
+	static DEFINE_MUTEX(cacheflush_mutex);
 	struct vm_area_struct *vma;
 	int ret = -EINVAL;
 
-	lock_kernel();
+	mutex_lock(&cacheflush_mutex);
 	if (scope < FLUSH_SCOPE_LINE || scope > FLUSH_SCOPE_ALL ||
 	    cache & ~FLUSH_CACHE_BOTH)
 		goto out;
@@ -446,7 +447,7 @@ sys_cacheflush (unsigned long addr, int scope, int cache, unsigned long len)
 	    }
 	}
 out:
-	unlock_kernel();
+	mutex_unlock(&cacheflush_mutex);
 	return ret;
 }
 
Signature · 1 line
1.7.1
#6 lore raw

Re: [PATCH 07/18] m68k: remove big kernel lock

Quoted 3 lines · Arnd Bergmann

The cache flush code only locks against itself, so there is no excuse to use the BKL here. This replaces it with a local mutex in order to maintain serialization of flushes.

I don't think this needs a lock at all.

Andreas.

Signature · 3 lines
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#7 lore raw

Re: [PATCH 07/18] m68k: remove big kernel lock

Quoted 9 lines · Andreas Schwab
Quoted 3 lines · Arnd Bergmann

The cache flush code only locks against itself, so there is no excuse to use the BKL here. This replaces it with a local mutex in order to maintain serialization of flushes.

I don't think this needs a lock at all.

Quite likely, I just took the most conservative approach. If you want to queue a patch to drop the BKL from m68k, I'll happily drop this one from my series.

Arnd

#8 lore raw

Re: [PATCH 07/18] m68k: remove big kernel lock

Quoted 8 lines · Arnd Bergmann
Quoted 7 lines · Andreas Schwab
Quoted 3 lines · Arnd Bergmann

The cache flush code only locks against itself, so there is no excuse to use the BKL here. This replaces it with a local mutex in order to maintain serialization of flushes.

Quoted 5 lines
Quoted 1 line

I don't think this needs a lock at all.

Quite likely, I just took the most conservative approach. If you want to queue a patch to drop the BKL from m68k, I'll happily drop this one from my series.

I'm dropping the locking completely. Patch will follow.

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds

#9 lore raw

PATCH 8/18 parisc: remove big kernel lock

In reply to Arnd Bergmann

The parisc version of the perf code is sufficiently protected by its own spinlock, no need to use the BKL.

Cc Kyle McMartin <[email protected]>
Cc Helge Deller <[email protected]>
Cc "James E.J. Bottomley" <[email protected]>
---
 arch/parisc/kernel/perf.c |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
arch/parisc/kernel/perf.c +0 -4
index f9f6783..ba0c053 100644
@@ -46,7 +46,6 @@
 #include <linux/init.h>
 #include <linux/proc_fs.h>
 #include <linux/miscdevice.h>
-#include <linux/smp_lock.h>
 #include <linux/spinlock.h>
 
 #include <asm/uaccess.h>
@@ -261,16 +260,13 @@ printk("Preparing to start counters\n");
  */
 static int perf_open(struct inode *inode, struct file *file)
 {
-	lock_kernel();
 	spin_lock(&perf_lock);
 	if (perf_enabled) {
 		spin_unlock(&perf_lock);
-		unlock_kernel();
 		return -EBUSY;
 	}
 	perf_enabled = 1;
  	spin_unlock(&perf_lock);
-	unlock_kernel();
 
 	return 0;
 }
Signature · 1 line
1.7.1
#10 lore raw

Re: [PATCH 08/18] parisc: remove big kernel lock

Quoted 3 lines · Arnd Bergmann

The parisc version of the perf code is sufficiently protected by its own spinlock, no need to use the BKL.

I'd rather just remove the file entirely, as it doesn't work, probably will never work, and all the relevant people who could have made it work have left HP and so no longer have access to the documentation. I'll commit a patch removing it from the kernel for the next merge window.

Nice work Arnd, it's great to see the BKL finally gasping its last breaths. :)

--Kyle

#11 lore raw

PATCH 10/18 uml: kill big kernel lock

In reply to Arnd Bergmann

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.

---
 arch/um/drivers/harddog_kern.c   |   13 +++++++------
 arch/um/drivers/hostaudio_kern.c |    8 ++++----
 arch/um/drivers/ubd_kern.c       |    8 ++++----
 arch/um/kernel/exec.c            |    2 --
 4 files changed, 15 insertions(+), 16 deletions(-)
arch/um/drivers/harddog_kern.c +7 -6
index cfcac1f..8603627 100644
@@ -42,7 +42,7 @@
 #include <linux/miscdevice.h>
 #include <linux/watchdog.h>
 #include <linux/reboot.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/init.h>
 #include <linux/spinlock.h>
 #include <asm/uaccess.h>
@@ -50,6 +50,7 @@
 
 MODULE_LICENSE("GPL");
 
+static DEFINE_MUTEX(harddog_mutex);
 static DEFINE_SPINLOCK(lock);
 static int timer_alive;
 static int harddog_in_fd = -1;
@@ -66,7 +67,7 @@ static int harddog_open(struct inode *inode, struct file *file)
 	int err = -EBUSY;
 	char *sock = NULL;
 
-	lock_kernel();
+	mutex_lock(&harddog_mutex);
 	spin_lock(&lock);
 	if(timer_alive)
 		goto err;
@@ -83,11 +84,11 @@ static int harddog_open(struct inode *inode, struct file *file)
 
 	timer_alive = 1;
 	spin_unlock(&lock);
-	unlock_kernel();
+	mutex_unlock(&harddog_mutex);
 	return nonseekable_open(inode, file);
 err:
 	spin_unlock(&lock);
-	unlock_kernel();
+	mutex_unlock(&harddog_mutex);
 	return err;
 }
 
@@ -153,9 +154,9 @@ static long harddog_ioctl(struct file *file,
 {
 	long ret;
 
-	lock_kernel();
+	mutex_lock(&harddog_mutex);
 	ret = harddog_ioctl_unlocked(file, cmd, arg);
-	unlock_kernel();
+	mutex_unlock(&harddog_mutex);
 
 	return ret;
 }
arch/um/drivers/hostaudio_kern.c +4 -4
index 0c46e39..fde18dc 100644
@@ -202,9 +202,9 @@ static int hostaudio_open(struct inode *inode, struct file *file)
 		w = 1;
 
 	kparam_block_sysfs_write(dsp);
-	lock_kernel();
+	mutex_lock(&hostaudio_mutex);
 	ret = os_open_file(dsp, of_set_rw(OPENFLAGS(), r, w), 0);
-	unlock_kernel();
+	mutex_unlock(&hostaudio_mutex);
 	kparam_unblock_sysfs_write(dsp);
 
 	if (ret < 0) {
@@ -263,9 +263,9 @@ static int hostmixer_open_mixdev(struct inode *inode, struct file *file)
 		w = 1;
 
 	kparam_block_sysfs_write(mixer);
-	lock_kernel();
+	mutex_lock(&hostaudio_mutex);
 	ret = os_open_file(mixer, of_set_rw(OPENFLAGS(), r, w), 0);
-	unlock_kernel();
+	mutex_unlock(&hostaudio_mutex);
 	kparam_unblock_sysfs_write(mixer);
 
 	if (ret < 0) {
arch/um/drivers/ubd_kern.c +4 -4
index 1bcd208..dc73bc8 100644
@@ -1099,7 +1099,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
 	struct ubd *ubd_dev = disk->private_data;
 	int err = 0;
 
-	lock_kernel();
+	mutex_lock(&ubd_mutex);
 	if(ubd_dev->count == 0){
 		err = ubd_open_dev(ubd_dev);
 		if(err){
@@ -1118,7 +1118,7 @@ static int ubd_open(struct block_device *bdev, fmode_t mode)
 	        err = -EROFS;
 	}*/
 out:
-	unlock_kernel();
+	mutex_unlock(&ubd_mutex);
 	return err;
 }
 
@@ -1126,10 +1126,10 @@ static int ubd_release(struct gendisk *disk, fmode_t mode)
 {
 	struct ubd *ubd_dev = disk->private_data;
 
-	lock_kernel();
+	mutex_lock(&ubd_mutex);
 	if(--ubd_dev->count == 0)
 		ubd_close_dev(ubd_dev);
-	unlock_kernel();
+	mutex_unlock(&ubd_mutex);
 	return 0;
 }
 
arch/um/kernel/exec.c +0 -2
index cd145ed..460ce86 100644
@@ -78,13 +78,11 @@ long sys_execve(const char __user *file, char __user *__user *argv,
 	long error;
 	char *filename;
 
-	lock_kernel();
 	filename = getname(file);
 	error = PTR_ERR(filename);
 	if (IS_ERR(filename)) goto out;
 	error = execve1(filename, argv, env);
 	putname(filename);
  out:
-	unlock_kernel();
 	return error;
 }
Signature · 12 lines
1.7.1


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel
#12 lore raw

PATCH 13/18 i4l: kill big kernel lock

In reply to Arnd Bergmann

The isdn4linux driver uses the big kernel lock only to serialize access to a few fields in its own modem_info structure.

The easiest replacement is a driver-wide mutex. More fine-grained locking would be more appropriate here, but likely harder to implement.

---
 drivers/isdn/i4l/isdn_tty.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/isdn/i4l/isdn_tty.c +6 -5
index 51dc60d..981f7ab 100644
@@ -14,7 +14,7 @@
 #include <linux/isdn.h>
 #include <linux/slab.h>
 #include <linux/delay.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include "isdn_common.h"
 #include "isdn_tty.h"
 #ifdef CONFIG_ISDN_AUDIO
@@ -28,6 +28,7 @@
 
 /* Prototypes */
 
+static DEFINE_MUTEX(modem_info_mutex);
 static int isdn_tty_edit_at(const char *, int, modem_info *);
 static void isdn_tty_check_esc(const u_char *, u_char, int, int *, u_long *);
 static void isdn_tty_modem_reset_regs(modem_info *, int);
@@ -1354,14 +1355,14 @@ isdn_tty_tiocmget(struct tty_struct *tty, struct file *file)
 	if (tty->flags & (1 << TTY_IO_ERROR))
 		return -EIO;
 
-	lock_kernel();
+	mutex_lock(&modem_info_mutex);
 #ifdef ISDN_DEBUG_MODEM_IOCTL
 	printk(KERN_DEBUG "ttyI%d ioctl TIOCMGET\n", info->line);
 #endif
 
 	control = info->mcr;
 	status = info->msr;
-	unlock_kernel();
+	mutex_unlock(&modem_info_mutex);
 	return ((control & UART_MCR_RTS) ? TIOCM_RTS : 0)
 	    | ((control & UART_MCR_DTR) ? TIOCM_DTR : 0)
 	    | ((status & UART_MSR_DCD) ? TIOCM_CAR : 0)
@@ -1385,7 +1386,7 @@ isdn_tty_tiocmset(struct tty_struct *tty, struct file *file,
 	printk(KERN_DEBUG "ttyI%d ioctl TIOCMxxx: %x %x\n", info->line, set, clear);
 #endif
 
-	lock_kernel();
+	mutex_lock(&modem_info_mutex);
 	if (set & TIOCM_RTS)
 		info->mcr |= UART_MCR_RTS;
 	if (set & TIOCM_DTR) {
@@ -1407,7 +1408,7 @@ isdn_tty_tiocmset(struct tty_struct *tty, struct file *file,
 			isdn_tty_modem_hup(info, 1);
 		}
 	}
-	unlock_kernel();
+	mutex_unlock(&modem_info_mutex);
 	return 0;
 }
 
Signature · 1 line
1.7.1
maintainer Applied
#13 lore raw

Re: [PATCH 13/18] i4l: kill big kernel lock

From: Arnd Bergmann <[email protected]>
Date: Tue, 14 Sep 2010 21:35:04 +0200

Quoted 9 lines

The isdn4linux driver uses the big kernel lock only to serialize access to a few fields in its own modem_info structure.

The easiest replacement is a driver-wide mutex. More fine-grained locking would be more appropriate here, but likely harder to implement.

Applied.

#14 lore raw

PATCH 14/18 misdn: kill big kernel lock

In reply to Arnd Bergmann

The use of the big kernel lock in misdn is completely bogus, so let's just remove it.

---
 drivers/isdn/mISDN/stack.c |    7 -------
 1 files changed, 0 insertions(+), 7 deletions(-)
drivers/isdn/mISDN/stack.c +0 -7
index b159bd5..a5b632e 100644
@@ -18,7 +18,6 @@
 #include <linux/slab.h>
 #include <linux/mISDNif.h>
 #include <linux/kthread.h>
-#include <linux/smp_lock.h>
 #include "core.h"
 
 static u_int	*debug;
@@ -205,13 +204,7 @@ mISDNStackd(void *data)
 	struct mISDNstack *st = data;
 	int err = 0;
 
-#ifdef CONFIG_SMP
-	lock_kernel();
-#endif
 	sigfillset(&current->blocked);
-#ifdef CONFIG_SMP
-	unlock_kernel();
-#endif
 	if (*debug & DEBUG_MSG_THREAD)
 		printk(KERN_DEBUG "mISDNStackd %s started\n",
 		    dev_name(&st->dev->dev));
Signature · 1 line
1.7.1
#16 lore raw

PATCH 15/18 dvb/bt8xx: kill the big kernel lock

In reply to Arnd Bergmann

The bt8xx driver only uses the big kernel lock in its dst_ca_ioctl function and never to serialize against other code, so we can trivially replace it with a private mutex.

---
 drivers/media/dvb/bt8xx/dst_ca.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
drivers/media/dvb/bt8xx/dst_ca.c +4 -3
index cf87051..d75788b 100644
@@ -22,7 +22,7 @@
 #include <linux/module.h>
 #include <linux/slab.h>
 #include <linux/init.h>
-#include <linux/smp_lock.h>
+#include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/dvb/ca.h>
 #include "dvbdev.h"
@@ -52,6 +52,7 @@
 } while(0)
 
 
+static DEFINE_MUTEX(dst_ca_mutex);
 static unsigned int verbose = 5;
 module_param(verbose, int, 0644);
 MODULE_PARM_DESC(verbose, "verbose startup messages, default is 1 (yes)");
@@ -564,7 +565,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
 	void __user *arg = (void __user *)ioctl_arg;
 	int result = 0;
 
-	lock_kernel();
+	mutex_lock(&dst_ca_mutex);
 	dvbdev = file->private_data;
 	state = (struct dst_state *)dvbdev->priv;
 	p_ca_message = kmalloc(sizeof (struct ca_msg), GFP_KERNEL);
@@ -652,7 +653,7 @@ static long dst_ca_ioctl(struct file *file, unsigned int cmd, unsigned long ioct
 	kfree (p_ca_slot_info);
 	kfree (p_ca_caps);
 
-	unlock_kernel();
+	mutex_unlock(&dst_ca_mutex);
 	return result;
 }
 
Signature · 1 line
1.7.1
#17 lore raw

PATCH 16/18 dvb-core: kill the big kernel lock

In reply to Arnd Bergmann

The dvb core only uses the big kernel lock in the open and ioctl functions, which means it can be replaced with a dvb specific mutex. Fortunately, all the ioctl functions go through dvb_usercopy, so we can move the serialization in there.

---
 drivers/media/dvb/dvb-core/dmxdev.c         |   17 ++---------------
 drivers/media/dvb/dvb-core/dvb_ca_en50221.c |    8 +-------
 drivers/media/dvb/dvb-core/dvb_net.c        |    9 +--------
 drivers/media/dvb/dvb-core/dvbdev.c         |   17 +++++++----------
 4 files changed, 11 insertions(+), 40 deletions(-)
drivers/media/dvb/dvb-core/dmxdev.c +2 -15
index 0042306..2de13b0 100644
@@ -25,7 +25,6 @@
 #include <linux/slab.h>
 #include <linux/vmalloc.h>
 #include <linux/module.h>
-#include <linux/smp_lock.h>
 #include <linux/poll.h>
 #include <linux/ioctl.h>
 #include <linux/wait.h>
@@ -1088,13 +1087,7 @@ static int dvb_demux_do_ioctl(struct file *file,
 static long dvb_demux_ioctl(struct file *file, unsigned int cmd,
 			    unsigned long arg)
 {
-	int ret;
-
-	lock_kernel();
-	ret = dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
-	unlock_kernel();
-
-	return ret;
+	return dvb_usercopy(file, cmd, arg, dvb_demux_do_ioctl);
 }
 
 static unsigned int dvb_demux_poll(struct file *file, poll_table *wait)
@@ -1186,13 +1179,7 @@ static int dvb_dvr_do_ioctl(struct file *file,
 static long dvb_dvr_ioctl(struct file *file,
 			 unsigned int cmd, unsigned long arg)
 {
-	int ret;
-
-	lock_kernel();
-	ret = dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
-	unlock_kernel();
-
-	return ret;
+	return dvb_usercopy(file, cmd, arg, dvb_dvr_do_ioctl);
 }
 
 static unsigned int dvb_dvr_poll(struct file *file, poll_table *wait)
drivers/media/dvb/dvb-core/dvb_ca_en50221.c +1 -7
index cb97e6b..1723a98 100644
@@ -1259,13 +1259,7 @@ static int dvb_ca_en50221_io_do_ioctl(struct file *file,
 static long dvb_ca_en50221_io_ioctl(struct file *file,
 				    unsigned int cmd, unsigned long arg)
 {
-	int ret;
-
-	lock_kernel();
-	ret = dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
-	unlock_kernel();
-
-	return ret;
+	return dvb_usercopy(file, cmd, arg, dvb_ca_en50221_io_do_ioctl);
 }
 
 
drivers/media/dvb/dvb-core/dvb_net.c +1 -8
index 6c3a8a0..a080322 100644
@@ -59,7 +59,6 @@
 #include <linux/netdevice.h>
 #include <linux/etherdevice.h>
 #include <linux/dvb/net.h>
-#include <linux/smp_lock.h>
 #include <linux/uio.h>
 #include <asm/uaccess.h>
 #include <linux/crc32.h>
@@ -1445,13 +1444,7 @@ static int dvb_net_do_ioctl(struct file *file,
 static long dvb_net_ioctl(struct file *file,
 	      unsigned int cmd, unsigned long arg)
 {
-	int ret;
-
-	lock_kernel();
-	ret = dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
-	unlock_kernel();
-
-	return ret;
+	return dvb_usercopy(file, cmd, arg, dvb_net_do_ioctl);
 }
 
 static int dvb_net_close(struct inode *inode, struct file *file)
drivers/media/dvb/dvb-core/dvbdev.c +7 -10
index b915c39..28f486e 100644
@@ -32,9 +32,9 @@
 #include <linux/fs.h>
 #include <linux/cdev.h>
 #include <linux/mutex.h>
-#include <linux/smp_lock.h>
 #include "dvbdev.h"
 
+static DEFINE_MUTEX(dvbdev_mutex);
 static int dvbdev_debug;
 
 module_param(dvbdev_debug, int, 0644);
@@ -68,7 +68,7 @@ static int dvb_device_open(struct inode *inode, struct file *file)
 {
 	struct dvb_device *dvbdev;
 
-	lock_kernel();
+	mutex_lock(&dvbdev_mutex);
 	down_read(&minor_rwsem);
 	dvbdev = dvb_minors[iminor(inode)];
 
@@ -91,12 +91,12 @@ static int dvb_device_open(struct inode *inode, struct file *file)
 		}
 		fops_put(old_fops);
 		up_read(&minor_rwsem);
-		unlock_kernel();
+		mutex_unlock(&dvbdev_mutex);
 		return err;
 	}
 fail:
 	up_read(&minor_rwsem);
-	unlock_kernel();
+	mutex_unlock(&dvbdev_mutex);
 	return -ENODEV;
 }
 
@@ -158,7 +158,6 @@ long dvb_generic_ioctl(struct file *file,
 		       unsigned int cmd, unsigned long arg)
 {
 	struct dvb_device *dvbdev = file->private_data;
-	int ret;
 
 	if (!dvbdev)
 		return -ENODEV;
@@ -166,11 +165,7 @@ long dvb_generic_ioctl(struct file *file,
 	if (!dvbdev->kernel_ioctl)
 		return -EINVAL;
 
-	lock_kernel();
-	ret = dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
-	unlock_kernel();
-
-	return ret;
+	return dvb_usercopy(file, cmd, arg, dvbdev->kernel_ioctl);
 }
 EXPORT_SYMBOL(dvb_generic_ioctl);
 
@@ -421,8 +416,10 @@ int dvb_usercopy(struct file *file,
 	}
 
 	/* call driver */
+	mutex_lock(&dvbdev_mutex);
 	if ((err = func(file, cmd, parg)) == -ENOIOCTLCMD)
 		err = -EINVAL;
+	mutex_unlock(&dvbdev_mutex);
 
 	if (err < 0)
 		goto out;
Signature · 1 line
1.7.1
#18 lore raw
In reply to Arnd Bergmann
Quoted 3 lines · On Tue, 14 Sep 2010 21:34:51 +0200 Arnd Bergmann <[email protected]> wrote:

Stephen, please add git+ssh://master.kernel.org/pub/scm/linux/kernel/git/arnd/bkl.git config

Added from today.

Thanks for adding your subsystem tree as a participant of linux-next. As you may know, this is not a judgment of your code. The purpose of linux-next is for integration testing and to lower the impact of conflicts between subsystems in the next merge window.

You will need to ensure that the patches/commits in your tree/series have been:
* submitted under GPL v2 (or later) and include the Contributor's Signed-off-by,
* posted to the relevant mailing list,
* reviewed by you (or another maintainer of your subsystem tree),
* successfully unit tested, and
* destined for the current or next Linux merge window.

Basically, this should be just what you would send to Linus (or ask him to fetch). It is allowed to be rebased if you deem it necessary.

Signature · 15 lines
Cheers,
Stephen Rothwell 
[email protected]

Legal Stuff:
By participating in linux-next, your subsystem tree contributions are
public and will be included in the linux-next trees.  You may be sent
e-mail messages indicating errors or other issues when the
patches/commits from your subsystem tree are merged and tested in
linux-next.  These messages may also be cross-posted to the linux-next
mailing list, the linux-kernel mailing list, etc.  The linux-next tree
project and IBM (my employer) make no warranties regarding the linux-next
project, the testing procedures, the results, the e-mails, etc.  If you
don't agree to these ground rules, let me know and I'll remove your tree
from participation in linux-next.

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev

_______________________________________________
User-mode-linux-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel