Skip to contentSkip to conversation

BKL removal, assorted patches

PATCH Applied Arnd Bergmann 4 participants 14 messages Jul 3, 2010 – Aug 13, 2010

Subsystems (37)
lore
Share & tools
lore

Arnd Bergmann

author maintainer
#0 lore raw

cover BKL removal, assorted patches

These patches are necessary for the removal of the big kernel lock but don't fit in any other series.

The most important one is the addition of the CONFIG_BKL Kconfig symbol, which can be used to mark device drivers that are still using the BKL so we can build a kernel that does not provide or need it.

I'd like to add this series to linux-next and submit it for linux-2.6.36 inclusion, but would even more welcome the individual maintainers to pick up the respective patches and put them in their next trees.

Arnd

Cc Bob Picco <[email protected]>
Cc Clemens Ladisch <[email protected]>
Cc Geert Uytterhoeven <[email protected]>
Cc Heiko Carstens <[email protected]>
Cc Jaroslav Kysela <[email protected]>
Cc Jesse Barnes <[email protected]>
Cc Martin Schwidefsky <[email protected]>
Cc Takashi Iwai <[email protected]>
Cc Tejun Heo <[email protected]>

Arnd Bergmann (7):
do_coredump: do not take BKL
init: remove the BKL from startup code
hpet: kill BKL, add compat_ioctl proc/pci: kill BKL
dasd: no need for BKL in ioctl
isapnp: BKL removal
BKL: introduce CONFIG_BKL.

John Kacur (1):
soundcore_open: Reduce the area BKL coverage

 drivers/char/Kconfig            |    2 +-
 drivers/char/hpet.c             |   98 +++++++++++++++++++++++++-------------
 drivers/gpu/drm/Kconfig         |    5 +-
 drivers/hid/usbhid/Kconfig      |    2 +-
 drivers/isdn/Kconfig            |    1 +
 drivers/isdn/capi/Kconfig       |    2 +-
 drivers/isdn/mISDN/Kconfig      |    1 +
 drivers/media/Kconfig           |    3 +-
 drivers/misc/Kconfig            |    2 +-
 drivers/net/appletalk/Kconfig   |    1 +
 drivers/pci/proc.c              |    4 +-
 drivers/pnp/isapnp/proc.c       |   13 +++--
 drivers/s390/block/dasd_ioctl.c |   17 +------
 drivers/sbus/char/Kconfig       |    2 +-
 drivers/staging/sep/Kconfig     |    2 +-
 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/coda/Kconfig                 |    1 +
 fs/ecryptfs/Kconfig             |    1 +
 fs/exec.c                       |    6 --
 fs/fat/Kconfig                  |    2 +
 fs/freevxfs/Kconfig             |    1 +
 fs/hpfs/Kconfig                 |    1 +
 fs/isofs/Kconfig                |    1 +
 fs/jffs2/Kconfig                |    1 +
 fs/ncpfs/Kconfig                |    1 +
 fs/nfs/Kconfig                  |    2 +-
 fs/nfsd/Kconfig                 |    1 +
 fs/ocfs2/Kconfig                |    1 +
 fs/qnx4/Kconfig                 |    1 +
 fs/reiserfs/Kconfig             |    1 +
 fs/smbfs/Kconfig                |    1 +
 fs/squashfs/Kconfig             |    2 +-
 fs/udf/Kconfig                  |    1 +
 fs/ufs/Kconfig                  |    2 +-
 include/linux/smp_lock.h        |    7 ++-
 init/Kconfig                    |    2 +-
 init/main.c                     |    5 --
 kernel/trace/trace.c            |    8 ---
 lib/Kconfig.debug               |   14 +++++-
 net/ipx/Kconfig                 |    1 +
 net/irda/Kconfig                |    2 +-
 net/irda/irnet/Kconfig          |    2 +-
 net/x25/Kconfig                 |    2 +-
 sound/oss/Kconfig               |    2 +-
 sound/sound_core.c              |   13 +++--
 51 files changed, 145 insertions(+), 104 deletions(-)
author maintainer
#1 lore raw

PATCH 1/8 do_coredump: do not take BKL

core_pattern is not actually protected and hasn't been ever since we introduced procfs support for sysctl -- a _long_ time. Don't take it here either.

---
 fs/exec.c |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)
fs/exec.c +0 -6
index e19de6a..3d7aeeb 100644
@@ -1891,13 +1891,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
 	 */
 	clear_thread_flag(TIF_SIGPENDING);
 
-	/*
-	 * lock_kernel() because format_corename() is controlled by sysctl, which
-	 * uses lock_kernel()
-	 */
- 	lock_kernel();
 	ispipe = format_corename(corename, signr);
-	unlock_kernel();
 
  	if (ispipe) {
 		int dump_count;
Signature · 1 line
1.7.1
#2 lore raw

Re: [PATCH 1/8] do_coredump: do not take BKL

Quoted 6 lines · Arnd Bergmann

core_pattern is not actually protected and hasn't been ever since we introduced procfs support for sysctl -- a _long_ time. Don't take it here either.

---

Applied in bkl/core, thanks.

author maintainer
#3 lore raw

PATCH 2/8 init: remove the BKL from startup code

In reply to Arnd Bergmann

I have shown by code review that no driver takes the BKL at init time any more, so whatever the init code was locking against is no longer there and it is now safe to remove the BKL there.

---
 init/main.c          |    5 -----
 kernel/trace/trace.c |    8 --------
 2 files changed, 0 insertions(+), 13 deletions(-)
init/main.c +0 -5
index a42fdf4..9b34c1b 100644
@@ -444,7 +444,6 @@ static noinline void __init_refok rest_init(void)
 	kthreadd_task = find_task_by_pid_ns(pid, &init_pid_ns);
 	rcu_read_unlock();
 	complete(&kthreadd_done);
-	unlock_kernel();
 
 	/*
 	 * The boot idle thread must execute schedule()
@@ -565,7 +564,6 @@ asmlinkage void __init start_kernel(void)
  * Interrupts are still disabled. Do necessary setups, then
  * enable them
  */
-	lock_kernel();
 	tick_init();
 	boot_cpu_init();
 	page_address_init();
@@ -829,7 +827,6 @@ static noinline int init_post(void)
 	/* need to finish all async __init code before freeing the memory */
 	async_synchronize_full();
 	free_initmem();
-	unlock_kernel();
 	mark_rodata_ro();
 	system_state = SYSTEM_RUNNING;
 	numa_default_policy();
@@ -869,8 +866,6 @@ static int __init kernel_init(void * unused)
 	 * Wait until kthreadd is all set-up.
 	 */
 	wait_for_completion(&kthreadd_done);
-	lock_kernel();
-
 	/*
 	 * init can allocate pages on any node
 	 */
kernel/trace/trace.c +0 -8
index 086d363..8047ca5 100644
@@ -734,13 +734,6 @@ __acquires(kernel_lock)
 		return -1;
 	}
 
-	/*
-	 * When this gets called we hold the BKL which means that
-	 * preemption is disabled. Various trace selftests however
-	 * need to disable and enable preemption for successful tests.
-	 * So we drop the BKL here and grab it after the tests again.
-	 */
-	unlock_kernel();
 	mutex_lock(&trace_types_lock);
 
 	tracing_selftest_running = true;
@@ -822,7 +815,6 @@ __acquires(kernel_lock)
 #endif
 
  out_unlock:
-	lock_kernel();
 	return ret;
 }
 
Signature · 1 line
1.7.1
#5 lore raw

Re: [PATCH 2/8] init: remove the BKL from startup code

In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

I have shown by code review that no driver takes the BKL at init time any more, so whatever the init code was locking against is no longer there and it is now safe to remove the BKL there.

---

Just trying to find any possible races here but I can't find any obvious. But I hope other reviewers can give it a look.

In the meantime, I'll queue that in my bkl/core branch so that it can live some times in linux-next.

Thanks.

author maintainer
#6 lore raw

PATCH 3/8 hpet: kill BKL, add compat_ioctl

In reply to Arnd Bergmann

hpet uses the big kernel lock in its ioctl and open functions. Replace this with a private mutex to be sure. Since we're already touching the ioctl function, add the compat_ioctl version as well -- all commands except HPET_INFO are compatible and that one is easy to add.

Cc Clemens Ladisch <[email protected]>
Cc Bob Picco <[email protected]>
---
 drivers/char/hpet.c |   98 +++++++++++++++++++++++++++++++++------------------
 1 files changed, 64 insertions(+), 34 deletions(-)
drivers/char/hpet.c +64 -34
index a0a1829..a4eee32 100644
@@ -30,6 +30,7 @@
 #include <linux/bcd.h>
 #include <linux/seq_file.h>
 #include <linux/bitops.h>
+#include <linux/compat.h>
 #include <linux/clocksource.h>
 #include <linux/slab.h>
 
@@ -67,6 +68,7 @@
 #define	read_counter(MC)	readl(MC)
 #endif
 
+static DEFINE_MUTEX(hpet_mutex); /* replaces BKL */
 static u32 hpet_nhpet, hpet_max_freq = HPET_USER_FREQ;
 
 /* This clocksource driver currently only works on ia64 */
@@ -250,7 +252,7 @@ static int hpet_open(struct inode *inode, struct file *file)
 	if (file->f_mode & FMODE_WRITE)
 		return -EINVAL;
 
-	lock_kernel();
+	mutex_lock(&hpet_mutex);
 	spin_lock_irq(&hpet_lock);
 
 	for (devp = NULL, hpetp = hpets; hpetp && !devp; hpetp = hpetp->hp_next)
@@ -264,7 +266,7 @@ static int hpet_open(struct inode *inode, struct file *file)
 
 	if (!devp) {
 		spin_unlock_irq(&hpet_lock);
-		unlock_kernel();
+		mutex_unlock(&hpet_mutex);
 		return -EBUSY;
 	}
 
@@ -272,7 +274,7 @@ static int hpet_open(struct inode *inode, struct file *file)
 	devp->hd_irqdata = 0;
 	devp->hd_flags |= HPET_OPEN;
 	spin_unlock_irq(&hpet_lock);
-	unlock_kernel();
+	mutex_unlock(&hpet_mutex);
 
 	hpet_timer_set_irq(devp);
 
@@ -429,22 +431,6 @@ static int hpet_release(struct inode *inode, struct file *file)
 	return 0;
 }
 
-static int hpet_ioctl_common(struct hpet_dev *, int, unsigned long, int);
-
-static long hpet_ioctl(struct file *file, unsigned int cmd,
-			unsigned long arg)
-{
-	struct hpet_dev *devp;
-	int ret;
-
-	devp = file->private_data;
-	lock_kernel();
-	ret = hpet_ioctl_common(devp, cmd, arg, 0);
-	unlock_kernel();
-
-	return ret;
-}
-
 static int hpet_ioctl_ieon(struct hpet_dev *devp)
 {
 	struct hpet_timer __iomem *timer;
@@ -553,7 +539,8 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
 }
 
 static int
-hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
+hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
+		  struct hpet_info *info)
 {
 	struct hpet_timer __iomem *timer;
 	struct hpet __iomem *hpet;
@@ -594,23 +581,15 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
 		break;
 	case HPET_INFO:
 		{
-			struct hpet_info info;
-
 			if (devp->hd_ireqfreq)
-				info.hi_ireqfreq =
+				info->hi_ireqfreq =
 					hpet_time_div(hpetp, devp->hd_ireqfreq);
 			else
-				info.hi_ireqfreq = 0;
-			info.hi_flags =
+				info->hi_ireqfreq = 0;
+			info->hi_flags =
 			    readq(&timer->hpet_config) & Tn_PER_INT_CAP_MASK;
-			info.hi_hpet = hpetp->hp_which;
-			info.hi_timer = devp - hpetp->hp_dev;
-			if (kernel)
-				memcpy((void *)arg, &info, sizeof(info));
-			else
-				if (copy_to_user((void __user *)arg, &info,
-						 sizeof(info)))
-					err = -EFAULT;
+			info->hi_hpet = hpetp->hp_which;
+			info->hi_timer = devp - hpetp->hp_dev;
 			break;
 		}
 	case HPET_EPI:
@@ -636,7 +615,7 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
 		devp->hd_flags &= ~HPET_PERIODIC;
 		break;
 	case HPET_IRQFREQ:
-		if (!kernel && (arg > hpet_max_freq) &&
+		if ((arg > hpet_max_freq) &&
 		    !capable(CAP_SYS_RESOURCE)) {
 			err = -EACCES;
 			break;
@@ -653,12 +632,63 @@ hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg, int kernel)
 	return err;
 }
 
+static long
+hpet_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct hpet_info info;
+	int err;
+
+	mutex_lock(&hpet_mutex);
+	err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
+	mutex_unlock(&hpet_mutex);
+
+	if ((cmd == HPET_INFO) && !err &&
+	    (copy_to_user((void __user *)arg, &info, sizeof(info))))
+		err = -EFAULT;
+
+	return err;
+}
+
+#ifdef CONFIG_COMPAT
+struct compat_hpet_info {
+	compat_ulong_t hi_ireqfreq;	/* Hz */
+	compat_ulong_t hi_flags;	/* information */
+	unsigned short hi_hpet;
+	unsigned short hi_timer;
+};
+
+static long
+hpet_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
+{
+	struct hpet_info info;
+	int err;
+
+	mutex_lock(&hpet_mutex);
+	err = hpet_ioctl_common(file->private_data, cmd, arg, &info);
+	mutex_unlock(&hpet_mutex);
+
+	if ((cmd == HPET_INFO) && !err) {
+		struct compat_hpet_info __user *u = compat_ptr(arg);
+		if (put_user(info.hi_ireqfreq, &u->hi_ireqfreq) ||
+		    put_user(info.hi_flags, &u->hi_flags) ||
+		    put_user(info.hi_hpet, &u->hi_hpet) ||
+		    put_user(info.hi_timer, &u->hi_timer))
+			err = -EFAULT;
+	}
+
+	return err;
+}
+#endif
+
 static const struct file_operations hpet_fops = {
 	.owner = THIS_MODULE,
 	.llseek = no_llseek,
 	.read = hpet_read,
 	.poll = hpet_poll,
 	.unlocked_ioctl = hpet_ioctl,
+#ifdef CONFIG_COMPAT
+	.compat_ioctl = hpet_compat_ioctl,
+#endif
 	.open = hpet_open,
 	.release = hpet_release,
 	.fasync = hpet_fasync,
Signature · 1 line
1.7.1
author maintainer
#7 lore raw

PATCH 4/8 proc/pci: kill BKL

In reply to Arnd Bergmann

All operations in the pci procfs ioctl functions are atomic, so no lock is needed here.

Also add a compat_ioctl method, since all the commands are compatible in 32 bit mode.

---
 drivers/pci/proc.c |    4 +---
 1 files changed, 1 insertions(+), 3 deletions(-)
drivers/pci/proc.c +1 -3
index 449e890..35b80c7 100644
@@ -212,8 +212,6 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
 #endif /* HAVE_PCI_MMAP */
 	int ret = 0;
 
-	lock_kernel();
-
 	switch (cmd) {
 	case PCIIOC_CONTROLLER:
 		ret = pci_domain_nr(dev->bus);
@@ -242,7 +240,6 @@ static long proc_bus_pci_ioctl(struct file *file, unsigned int cmd,
 		break;
 	};
 
-	unlock_kernel();
 	return ret;
 }
 
@@ -306,6 +303,7 @@ static const struct file_operations proc_bus_pci_operations = {
 	.read		= proc_bus_pci_read,
 	.write		= proc_bus_pci_write,
 	.unlocked_ioctl	= proc_bus_pci_ioctl,
+	.compat_ioctl	= proc_bus_pci_ioctl,
 #ifdef HAVE_PCI_MMAP
 	.open		= proc_bus_pci_open,
 	.release	= proc_bus_pci_release,
Signature · 1 line
1.7.1
#8 lore raw

Re: [PATCH 4/8] proc/pci: kill BKL

Quoted 11 lines · On Sun, 4 Jul 2010 00:02:28 +0200 Arnd Bergmann <[email protected]> wrote:

All operations in the pci procfs ioctl functions are atomic, so no lock is needed here.

Also add a compat_ioctl method, since all the commands are compatible in 32 bit mode.

---

Oops, I had assumed this was going through some master 'kill the bkl' tree. Applied to my linux-next branch now though, sorry for the delay.

Signature · 1 line
Jesse Barnes, Intel Open Source Technology Center
author maintainer
#9 lore raw

PATCH 5/8 dasd: no need for BKL in ioctl

In reply to Arnd Bergmann

The dasd driver does not need the BKL, so we can remove it here as well.

Cc Martin Schwidefsky <[email protected]>
Cc Heiko Carstens <[email protected]>
---
 drivers/s390/block/dasd_ioctl.c |   17 ++---------------
 1 files changed, 2 insertions(+), 15 deletions(-)
drivers/s390/block/dasd_ioctl.c +2 -15
index 1557214..26075e9 100644
@@ -16,7 +16,6 @@
 #include <linux/major.h>
 #include <linux/fs.h>
 #include <linux/blkpg.h>
-#include <linux/smp_lock.h>
 #include <linux/slab.h>
 #include <asm/compat.h>
 #include <asm/ccwdev.h>
@@ -370,9 +369,8 @@ static int dasd_ioctl_readall_cmb(struct dasd_block *block, unsigned int cmd,
 	return ret;
 }
 
-static int
-dasd_do_ioctl(struct block_device *bdev, fmode_t mode,
-	      unsigned int cmd, unsigned long arg)
+int dasd_ioctl(struct block_device *bdev, fmode_t mode,
+	       unsigned int cmd, unsigned long arg)
 {
 	struct dasd_block *block = bdev->bd_disk->private_data;
 	void __user *argp;
@@ -430,14 +428,3 @@ dasd_do_ioctl(struct block_device *bdev, fmode_t mode,
 		return -EINVAL;
 	}
 }
-
-int dasd_ioctl(struct block_device *bdev, fmode_t mode,
-	       unsigned int cmd, unsigned long arg)
-{
-	int rc;
-
-	lock_kernel();
-	rc = dasd_do_ioctl(bdev, mode, cmd, arg);
-	unlock_kernel();
-	return rc;
-}
Signature · 1 line
1.7.1
author maintainer
#10 lore raw

PATCH 6/8 isapnp: BKL removal

In reply to Arnd Bergmann

Remove BKL use from isapnp_proc_bus_lseek(), like was done for proc_bus_pci_lseek() a long time ago and recently for Zorro by Geert Uytterhoeven.

Cc Geert Uytterhoeven <[email protected]>
Cc Jaroslav Kysela <[email protected]>
---
 drivers/pnp/isapnp/proc.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)
drivers/pnp/isapnp/proc.c +7 -6
index 3f94eda..4249999 100644
@@ -31,8 +31,9 @@ static struct proc_dir_entry *isapnp_proc_bus_dir = NULL;
 static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
 {
 	loff_t new = -1;
+	struct inode *inode = file->f_path.dentry->d_inode;
 
-	lock_kernel();
+	mutex_lock(&inode->i_mutex);
 	switch (whence) {
 	case 0:
 		new = off;
@@ -45,11 +46,11 @@ static loff_t isapnp_proc_bus_lseek(struct file *file, loff_t off, int whence)
 		break;
 	}
 	if (new < 0 || new > 256) {
-		unlock_kernel();
-		return -EINVAL;
-	}
-	unlock_kernel();
-	return (file->f_pos = new);
+		new = -EINVAL;
+	else
+		file->f_pos = new;
+	mutex_unlock(&inode->i_mutex);
+	return new;
 }
 
 static ssize_t isapnp_proc_bus_read(struct file *file, char __user * buf,
Signature · 1 line
1.7.1
author maintainer
#11 lore raw

PATCH 7/8 soundcore_open: Reduce the area BKL coverage

In reply to Arnd Bergmann

From: John Kacur <[email protected]>

Most of this function is protected by the sound_loader_lock.
We can push down the BKL to this call out err = file->f_op->open(inode,file);

In order to build the sound core without the BKL, we will need to push the lock_kernel() call into the ~20 device drivers that register their file operations.

---
 sound/sound_core.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
sound/sound_core.c +8 -5
index 7c2d677..c8627fc 100644
@@ -576,8 +576,6 @@ static int soundcore_open(struct inode *inode, struct file *file)
 	struct sound_unit *s;
 	const struct file_operations *new_fops = NULL;
 
-	lock_kernel ();
-
 	chain=unit&0x0F;
 	if(chain==4 || chain==5)	/* dsp/audio/dsp16 */
 	{
@@ -630,18 +628,23 @@ static int soundcore_open(struct inode *inode, struct file *file)
 		const struct file_operations *old_fops = file->f_op;
 		file->f_op = new_fops;
 		spin_unlock(&sound_loader_lock);
-		if(file->f_op->open)
+
+		if (file->f_op->open) {
+			/* TODO: push down BKL into indivial open functions */
+			lock_kernel();
 			err = file->f_op->open(inode,file);
+			unlock_kernel();
+		}
+
 		if (err) {
 			fops_put(file->f_op);
 			file->f_op = fops_get(old_fops);
 		}
+
 		fops_put(old_fops);
-		unlock_kernel();
 		return err;
 	}
 	spin_unlock(&sound_loader_lock);
-	unlock_kernel();
 	return -ENODEV;
 }
 
Signature · 1 line
1.7.1
Applied
#12 lore raw

Re: [PATCH 7/8] soundcore_open: Reduce the area BKL coverage

At Sun, 4 Jul 2010 00:02:31 +0200,

Quoted 6 lines · Arnd Bergmann

From: John Kacur <[email protected]>

Most of this function is protected by the sound_loader_lock.
We can push down the BKL to this call out err = file->f_op->open(inode,file);

Quoted 8 lines

In order to build the sound core without the BKL, we will need to push the lock_kernel() call into the ~20 device drivers that register their file operations.

I applied this one to sound git tree now. Thanks!

Takashi

Quoted 47 lines
---
 sound/sound_core.c |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
sound/sound_core.c +8 -5
index 7c2d677..c8627fc 100644
@@ -576,8 +576,6 @@ static int soundcore_open(struct inode *inode, struct file *file)
 	struct sound_unit *s;
 	const struct file_operations *new_fops = NULL;
 
-	lock_kernel ();
-
 	chain=unit&0x0F;
 	if(chain==4 || chain==5)	/* dsp/audio/dsp16 */
 	{
@@ -630,18 +628,23 @@ static int soundcore_open(struct inode *inode, struct file *file)
 		const struct file_operations *old_fops = file->f_op;
 		file->f_op = new_fops;
 		spin_unlock(&sound_loader_lock);
-		if(file->f_op->open)
+
+		if (file->f_op->open) {
+			/* TODO: push down BKL into indivial open functions */
+			lock_kernel();
 			err = file->f_op->open(inode,file);
+			unlock_kernel();
+		}
+
 		if (err) {
 			fops_put(file->f_op);
 			file->f_op = fops_get(old_fops);
 		}
+
 		fops_put(old_fops);
-		unlock_kernel();
 		return err;
 	}
 	spin_unlock(&sound_loader_lock);
-	unlock_kernel();
 	return -ENODEV;
 }
 
Signature · 1 line
1.7.1
author maintainer
#13 lore raw

PATCH 8/8 BKL: introduce CONFIG_BKL.

In reply to Arnd Bergmann

To make it possible to build a kernel without the big kernel lock, we need to make sure we don't build any code that still uses it, so disable the options in Kconfig.

Most of the v4l, drm and oss drivers still need it too, but their respective top-level interfaces get disabled here, so we don't need to list them separately.

For now, the option is invisible, which will change as soon as all dependencies have been merged. As of 2.6.35-rc3, this includes patch series for block and vfs super_operations as well as the final removal of the BKL from the ioctl and llseek path in VFS.

---
 drivers/char/Kconfig          |    2 +-
 drivers/gpu/drm/Kconfig       |    5 +++--
 drivers/hid/usbhid/Kconfig    |    2 +-
 drivers/isdn/Kconfig          |    1 +
 drivers/isdn/capi/Kconfig     |    2 +-
 drivers/isdn/mISDN/Kconfig    |    1 +
 drivers/media/Kconfig         |    3 ++-
 drivers/misc/Kconfig          |    2 +-
 drivers/net/appletalk/Kconfig |    1 +
 drivers/sbus/char/Kconfig     |    2 +-
 drivers/staging/sep/Kconfig   |    2 +-
 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/coda/Kconfig               |    1 +
 fs/ecryptfs/Kconfig           |    1 +
 fs/fat/Kconfig                |    2 ++
 fs/freevxfs/Kconfig           |    1 +
 fs/hpfs/Kconfig               |    1 +
 fs/isofs/Kconfig              |    1 +
 fs/jffs2/Kconfig              |    1 +
 fs/ncpfs/Kconfig              |    1 +
 fs/nfs/Kconfig                |    2 +-
 fs/nfsd/Kconfig               |    1 +
 fs/ocfs2/Kconfig              |    1 +
 fs/qnx4/Kconfig               |    1 +
 fs/reiserfs/Kconfig           |    1 +
 fs/smbfs/Kconfig              |    1 +
 fs/squashfs/Kconfig           |    2 +-
 fs/udf/Kconfig                |    1 +
 fs/ufs/Kconfig                |    2 +-
 include/linux/smp_lock.h      |    7 +++++--
 init/Kconfig                  |    2 +-
 lib/Kconfig.debug             |   14 +++++++++++++-
 net/ipx/Kconfig               |    1 +
 net/irda/Kconfig              |    2 +-
 net/irda/irnet/Kconfig        |    2 +-
 net/x25/Kconfig               |    2 +-
 sound/oss/Kconfig             |    2 +-
 43 files changed, 63 insertions(+), 22 deletions(-)
drivers/char/Kconfig +1 -1
index 7cfcc62..40cc670 100644
@@ -129,7 +129,7 @@ config SERIAL_NONSTANDARD
 
 config COMPUTONE
 	tristate "Computone IntelliPort Plus serial support"
-	depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI)
+	depends on SERIAL_NONSTANDARD && (ISA || EISA || PCI) && BKL
 	---help---
 	  This driver supports the entire family of Intelliport II/Plus
 	  controllers with the exception of the MicroChannel controllers and
drivers/gpu/drm/Kconfig +3 -2
index 88910e5..f59e263 100644
@@ -6,7 +6,7 @@
 #
 menuconfig DRM
 	tristate "Direct Rendering Manager (XFree86 4.1.0 and higher DRI support)"
-	depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU
+	depends on (AGP || AGP=n) && PCI && !EMULATED_CMPXCHG && MMU && BKL
 	select I2C
 	select I2C_ALGOBIT
 	select SLOW_WORK
@@ -72,7 +72,7 @@ source "drivers/gpu/drm/radeon/Kconfig"
 
 config DRM_I810
 	tristate "Intel I810"
-	depends on DRM && AGP && AGP_INTEL
+	depends on DRM && AGP && AGP_INTEL && BKL
 	help
 	  Choose this option if you have an Intel I810 graphics card.  If M is
 	  selected, the module will be called i810.  AGP support is required
@@ -85,6 +85,7 @@ choice
 
 config DRM_I830
 	tristate "i830 driver"
+	depends on BKL
 	help
 	  Choose this option if you have a system that has Intel 830M, 845G,
 	  852GM, 855GM or 865G integrated graphics.  If M is selected, the
drivers/hid/usbhid/Kconfig +1 -1
index 4edb3be..deee423 100644
@@ -4,7 +4,7 @@ comment "USB Input Devices"
 config USB_HID
 	tristate "USB Human Interface Device (full HID) support"
 	default y
-	depends on USB && INPUT
+	depends on USB && INPUT && BKL
 	select HID
 	---help---
 	  Say Y here if you want full HID support to connect USB keyboards,
drivers/isdn/Kconfig +1 -0
index 4fb6016..ecf58c5 100644
@@ -22,6 +22,7 @@ if ISDN
 
 menuconfig ISDN_I4L
 	tristate "Old ISDN4Linux (deprecated)"
+	depends on BKL
 	---help---
 	  This driver allows you to use an ISDN adapter for networking
 	  connections and as dialin/out device.  The isdn-tty's have a built
drivers/isdn/capi/Kconfig +1 -1
index a168e8a..bb40d8d 100644
@@ -35,7 +35,7 @@ config ISDN_CAPI_CAPI20
 
 config ISDN_CAPI_CAPIFS_BOOL
 	bool "CAPI2.0 filesystem support (DEPRECATED)"
-	depends on ISDN_CAPI_MIDDLEWARE && ISDN_CAPI_CAPI20
+	depends on ISDN_CAPI_MIDDLEWARE && ISDN_CAPI_CAPI20 && BKL
 	help
 	  This option provides a special file system, similar to /dev/pts with
 	  device nodes for the special ttys established by using the
drivers/isdn/mISDN/Kconfig +1 -0
index 1747a02..ba4fbd9 100644
@@ -4,6 +4,7 @@
 
 menuconfig MISDN
 	tristate "Modular ISDN driver"
+	depends on BKL
 	help
 	  Enable support for the modular ISDN driver.
 
drivers/media/Kconfig +2 -1
index a28541b..95d2a8b 100644
@@ -19,6 +19,7 @@ comment "Multimedia core support"
 
 config VIDEO_DEV
 	tristate "Video For Linux"
+	depends on BKL
 	---help---
 	  V4L core support for video capture and overlay devices, webcams and
 	  AM/FM radio cards.
@@ -75,7 +76,7 @@ config VIDEO_V4L1_COMPAT
 
 config DVB_CORE
 	tristate "DVB for Linux"
-	depends on NET && INET
+	depends on NET && INET && BKL
 	select CRC32
 	help
 	  DVB core utility functions for device handling, software fallbacks etc.
drivers/misc/Kconfig +1 -1
index 26386a9..a79d8d2 100644
@@ -263,7 +263,7 @@ config HP_ILO
 
 config SGI_GRU
 	tristate "SGI GRU driver"
-	depends on X86_UV && SMP
+	depends on X86_UV && SMP && BKL
 	default n
 	select MMU_NOTIFIER
 	---help---
drivers/net/appletalk/Kconfig +1 -0
index 0a0e0cd..04fa1e7 100644
@@ -3,6 +3,7 @@
 #
 config ATALK
 	tristate "Appletalk protocol support"
+	depends on BKL
 	select LLC
 	---help---
 	  AppleTalk is the protocol that Apple computers can use to communicate
drivers/sbus/char/Kconfig +1 -1
index 73cde85..b0272e2 100644
@@ -31,7 +31,7 @@ config TADPOLE_TS102_UCTRL
 
 config SUN_JSFLASH
 	tristate "JavaStation OS Flash SIMM (EXPERIMENTAL)"
-	depends on EXPERIMENTAL && SPARC32
+	depends on EXPERIMENTAL && SPARC32 && BKL
 	help
 	  If you say Y here, you will be able to boot from your JavaStation's
 	  Flash memory.
drivers/staging/sep/Kconfig +1 -1
index 0a9c39c..ae1e181 100644
@@ -1,7 +1,7 @@
 config DX_SEP
 	tristate "Discretix SEP driver"
 #	depends on MRST
-	depends on RAR_REGISTER && PCI
+	depends on RAR_REGISTER && PCI && BKL
 	default y
 	help
 	  Discretix SEP driver
drivers/staging/usbip/Kconfig +1 -1
index 2c1d10a..b11ec37 100644
@@ -1,6 +1,6 @@
 config USB_IP_COMMON
 	tristate "USB IP support (EXPERIMENTAL)"
-	depends on USB && NET && EXPERIMENTAL
+	depends on USB && NET && EXPERIMENTAL && BKL
 	default N
 	---help---
 	  This enables pushing USB packets over IP to allow remote
drivers/usb/gadget/Kconfig +1 -1
index 591ae9f..39a80c6 100644
@@ -697,7 +697,7 @@ config USB_ETH_EEM
 
 config USB_GADGETFS
 	tristate "Gadget Filesystem (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	depends on EXPERIMENTAL && BKL
 	help
 	  This driver provides a filesystem based API that lets user mode
 	  programs implement a single-configuration USB device, including
fs/Kconfig +1 -0
index 5f85b59..ba772ef 100644
@@ -49,6 +49,7 @@ endif # BLOCK
 
 config FILE_LOCKING
 	bool "Enable POSIX file locking API" if EMBEDDED
+	depends on BKL
 	default y
 	help
 	  This option enables standard file locking support, required
fs/adfs/Kconfig +1 -0
index e55182a..d72c786 100644
@@ -1,6 +1,7 @@
 config ADFS_FS
 	tristate "ADFS file system support (EXPERIMENTAL)"
 	depends on BLOCK && EXPERIMENTAL
+	depends on BKL
 	help
 	  The Acorn Disc Filing System is the standard file system of the
 	  RiscOS operating system which runs on Acorn's ARM-based Risc PC
fs/afs/Kconfig +1 -0
index 5c4e61d..0874017 100644
@@ -1,6 +1,7 @@
 config AFS_FS
 	tristate "Andrew File System support (AFS) (EXPERIMENTAL)"
 	depends on INET && EXPERIMENTAL
+	depends on BKL
 	select AF_RXRPC
 	help
 	  If you say Y here, you will get an experimental Andrew File System
fs/autofs/Kconfig +1 -0
index 5f3bea9..9126a42 100644
@@ -1,5 +1,6 @@
 config AUTOFS_FS
 	tristate "Kernel automounter support"
+	depends on BKL
 	help
 	  The automounter is a tool to automatically mount remote file systems
 	  on demand. This implementation is partially kernel-based to reduce
fs/autofs4/Kconfig +1 -0
index 1204d63..06831b5 100644
@@ -1,5 +1,6 @@
 config AUTOFS4_FS
 	tristate "Kernel automounter version 4 support (also supports v3)"
+	depends on BKL
 	help
 	  The automounter is a tool to automatically mount remote file systems
 	  on demand. This implementation is partially kernel-based to reduce
fs/coda/Kconfig +1 -0
index c0e5a7f..8689de8 100644
@@ -1,6 +1,7 @@
 config CODA_FS
 	tristate "Coda file system support (advanced network fs)"
 	depends on INET
+	depends on BKL
 	help
 	  Coda is an advanced network file system, similar to NFS in that it
 	  enables you to mount file systems of a remote server and access them
fs/ecryptfs/Kconfig +1 -0
index 1cd6d9d..2e8660f 100644
@@ -1,6 +1,7 @@
 config ECRYPT_FS
 	tristate "eCrypt filesystem layer support (EXPERIMENTAL)"
 	depends on EXPERIMENTAL && KEYS && CRYPTO
+	depends on BKL
 	select CRYPTO_ECB
 	select CRYPTO_CBC
 	select CRYPTO_MD5
fs/fat/Kconfig +2 -0
index 182f9ff..c4777ea 100644
@@ -34,6 +34,7 @@ config FAT_FS
 
 config MSDOS_FS
 	tristate "MSDOS fs support"
+	depends on BKL
 	select FAT_FS
 	help
 	  This allows you to mount MSDOS partitions of your hard drive (unless
@@ -59,6 +60,7 @@ config MSDOS_FS
 
 config VFAT_FS
 	tristate "VFAT (Windows-95) fs support"
+	depends on BKL
 	select FAT_FS
 	help
 	  This option provides support for normal Windows file systems with
fs/freevxfs/Kconfig +1 -0
index 8dc1cd5..aba5cb5 100644
@@ -1,6 +1,7 @@
 config VXFS_FS
 	tristate "FreeVxFS file system support (VERITAS VxFS(TM) compatible)"
 	depends on BLOCK
+	depends on BKL
 	help
 	  FreeVxFS is a file system driver that support the VERITAS VxFS(TM)
 	  file system format.  VERITAS VxFS(TM) is the standard file system
fs/hpfs/Kconfig +1 -0
index 56bd15c..1012579 100644
@@ -1,6 +1,7 @@
 config HPFS_FS
 	tristate "OS/2 HPFS file system support"
 	depends on BLOCK
+	depends on BKL
 	help
 	  OS/2 is IBM's operating system for PC's, the same as Warp, and HPFS
 	  is the file system used for organizing files on OS/2 hard disk
fs/isofs/Kconfig +1 -0
index 8ab9878..2c45a34 100644
@@ -1,5 +1,6 @@
 config ISO9660_FS
 	tristate "ISO 9660 CDROM file system support"
+	depends on BKL
 	help
 	  This is the standard file system used on CD-ROMs.  It was previously
 	  known as "High Sierra File System" and is called "hsfs" on other
fs/jffs2/Kconfig +1 -0
index 6ae169c..d13b148 100644
@@ -1,6 +1,7 @@
 config JFFS2_FS
 	tristate "Journalling Flash File System v2 (JFFS2) support"
 	select CRC32
+	depends on BKL
 	depends on MTD
 	help
 	  JFFS2 is the second generation of the Journalling Flash File System
fs/ncpfs/Kconfig +1 -0
index c931cf2..d0ed28d 100644
@@ -3,6 +3,7 @@
 #
 config NCP_FS
 	tristate "NCP file system support (to mount NetWare volumes)"
+	depends on BKL
 	depends on IPX!=n || INET
 	help
 	  NCP (NetWare Core Protocol) is a protocol that runs over IPX and is
fs/nfs/Kconfig +1 -1
index a43d07e..16ab92c 100644
@@ -1,6 +1,6 @@
 config NFS_FS
 	tristate "NFS client support"
-	depends on INET && FILE_LOCKING
+	depends on INET && FILE_LOCKING && BKL
 	select LOCKD
 	select SUNRPC
 	select NFS_ACL_SUPPORT if NFS_V3_ACL
fs/nfsd/Kconfig +1 -0
index 503b9da..afdf7ce 100644
@@ -2,6 +2,7 @@ config NFSD
 	tristate "NFS server support"
 	depends on INET
 	depends on FILE_LOCKING
+	depends on BKL
 	select LOCKD
 	select SUNRPC
 	select EXPORTFS
fs/ocfs2/Kconfig +1 -0
index 0d84066..11b66d0 100644
@@ -1,5 +1,6 @@
 config OCFS2_FS
 	tristate "OCFS2 file system support"
+	depends on BKL
 	depends on NET && SYSFS
 	select CONFIGFS_FS
 	select JBD2
fs/qnx4/Kconfig +1 -0
index 5f60899..4fae4a9 100644
@@ -1,5 +1,6 @@
 config QNX4FS_FS
 	tristate "QNX4 file system support (read only)"
+	depends on BKL
 	depends on BLOCK
 	help
 	  This is the file system used by the real-time operating systems
fs/reiserfs/Kconfig +1 -0
index 513f431..d9ac7c5 100644
@@ -1,5 +1,6 @@
 config REISERFS_FS
 	tristate "Reiserfs support"
+	depends on BKL
 	select CRC32
 	help
 	  Stores not just filenames but the files themselves in a balanced
fs/smbfs/Kconfig +1 -0
index e668127..5361221 100644
@@ -1,5 +1,6 @@
 config SMB_FS
 	tristate "SMB file system support (OBSOLETE, please use CIFS)"
+	depends on BKL
 	depends on INET
 	select NLS
 	help
fs/squashfs/Kconfig +1 -1
index cc6ce8a..26fcaf3 100644
@@ -1,6 +1,6 @@
 config SQUASHFS
 	tristate "SquashFS 4.0 - Squashed file system support"
-	depends on BLOCK
+	depends on BLOCK && BKL
 	select ZLIB_INFLATE
 	help
 	  Saying Y here includes support for SquashFS 4.0 (a Compressed
fs/udf/Kconfig +1 -0
index 0e0e99b..b344257 100644
@@ -1,5 +1,6 @@
 config UDF_FS
 	tristate "UDF file system support"
+	depends on BKL
 	select CRC_ITU_T
 	help
 	  This is the new file system used on some CD-ROMs and DVDs. Say Y if
fs/ufs/Kconfig +1 -1
index e4f10a4..7f1410f 100644
@@ -1,6 +1,6 @@
 config UFS_FS
 	tristate "UFS file system support (read only)"
-	depends on BLOCK
+	depends on BLOCK && BKL
 	help
 	  BSD and derivate versions of Unix (such as SunOS, FreeBSD, NetBSD,
 	  OpenBSD and NeXTstep) use a file system called UFS. Some System V
include/linux/smp_lock.h +5 -2
index 2ea1dd1..291f721 100644
@@ -54,12 +54,15 @@ static inline void cycle_kernel_lock(void)
 
 #else
 
+#ifdef CONFIG_BKL /* provoke build bug if not set */
 #define lock_kernel()
 #define unlock_kernel()
-#define release_kernel_lock(task)		do { } while(0)
 #define cycle_kernel_lock()			do { } while(0)
-#define reacquire_kernel_lock(task)		0
 #define kernel_locked()				1
+#endif /* CONFIG_BKL */
+
+#define release_kernel_lock(task)		do { } while(0)
+#define reacquire_kernel_lock(task)		0
 
 #endif /* CONFIG_LOCK_KERNEL */
 #endif /* __LINUX_SMPLOCK_H */
init/Kconfig +1 -1
index 5cff9a9..8cbc035 100644
@@ -64,7 +64,7 @@ config BROKEN_ON_SMP
 
 config LOCK_KERNEL
 	bool
-	depends on SMP || PREEMPT
+	depends on (SMP || PREEMPT) && BKL
 	default y
 
 config INIT_ENV_ARG_LIMIT
lib/Kconfig.debug +13 -1
index e722e9d..84ef129 100644
@@ -424,7 +424,7 @@ config DEBUG_PI_LIST
 
 config RT_MUTEX_TESTER
 	bool "Built-in scriptable tester for rt-mutexes"
-	depends on DEBUG_KERNEL && RT_MUTEXES
+	depends on DEBUG_KERNEL && RT_MUTEXES && BKL = y
 	help
 	  This option enables a rt-mutex tester.
 
@@ -444,6 +444,18 @@ config DEBUG_MUTEXES
 	 This feature allows mutex semantics violations to be detected and
 	 reported.
 
+config BKL
+	bool "Big Kernel Lock" if (SMP || PREEMPT) && BROKEN
+	default y
+	help
+	  This is the traditional lock that is used in old code instead
+	  of proper locking. All drivers that use the BKL should depend
+	  on this symbol.
+	  Say Y here unless you are working on removing the BKL.
+
+	  The option depends on CONFIG_BROKEN as long as the BKL is still
+	  used in the VFS and block layer.
+
 config DEBUG_LOCK_ALLOC
 	bool "Lock debugging: detect incorrect freeing of live locks"
 	depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
net/ipx/Kconfig +1 -0
index e9ad006..45b232e 100644
@@ -3,6 +3,7 @@
 #
 config IPX
 	tristate "The IPX protocol"
+	depends on BKL
 	select LLC
 	---help---
 	  This is support for the Novell networking protocol, IPX, commonly
net/irda/Kconfig +1 -1
index c8671a7..b92874b 100644
@@ -3,7 +3,7 @@
 #
 
 menuconfig IRDA
-	depends on NET && !S390
+	depends on NET && !S390 && BKL
 	tristate "IrDA (infrared) subsystem support"
 	select CRC_CCITT
 	---help---
net/irda/irnet/Kconfig +1 -1
index 28c557f..4646380 100644
@@ -1,6 +1,6 @@
 config IRNET
 	tristate "IrNET protocol"
-	depends on IRDA && PPP
+	depends on IRDA && PPP && BKL
 	help
 	  Say Y here if you want to build support for the IrNET protocol.
 	  To compile it as a module, choose M here: the module will be
net/x25/Kconfig +1 -1
index e6759c9..71f3164 100644
@@ -4,7 +4,7 @@
 
 config X25
 	tristate "CCITT X.25 Packet Layer (EXPERIMENTAL)"
-	depends on EXPERIMENTAL
+	depends on EXPERIMENTAL && BKL
 	---help---
 	  X.25 is a set of standardized network protocols, similar in scope to
 	  frame relay; the one physical line from your box to the X.25 network
sound/oss/Kconfig +1 -1
index a513651..9552197 100644
@@ -253,7 +253,7 @@ config MSND_FIFOSIZE
 
 menuconfig SOUND_OSS
 	tristate "OSS sound modules"
-	depends on ISA_DMA_API && VIRT_TO_BUS
+	depends on ISA_DMA_API && VIRT_TO_BUS && BKL
 	help
 	  OSS is the Open Sound System suite of sound card drivers.  They make
 	  sound programming easier since they provide a common API.  Say Y or
Signature · 1 line
1.7.1