All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 2.6.8.1 MegaRAID Driver Race
@ 2004-08-23 21:57 bradgoodman.com
  2004-08-23 22:16 ` Andrew Morton
  2004-08-28 19:15 ` Alan Cox
  0 siblings, 2 replies; 3+ messages in thread
From: bradgoodman.com @ 2004-08-23 21:57 UTC (permalink / raw)
  To: akpm, Atul.Mukker, bgoodman, linux-kernel, marcelo, torvalds

[PATCH] 2.6.8.1 to LSI Logic MegaRAID Adapter - ioctl function calls 
mega_internal_command, which uses wait_event, which calls schedule.
This means schedule() is called while big kernel_lock is held.

Locks/Unlocks were done here because 

1. There are a lot of return()s in the ioctl function to dodge.
2. mega_internal_command is also called by read and writes,
   which don't hold big kernel_lock

Brad Goodman <brad@bradgoodman.com>


--- drivers/scsi/megaraid.c.orig	Mon Aug 23 15:57:09 2004
+++ drivers/scsi/megaraid.c	Mon Aug 23 15:18:48 2004
@@ -38,6 +38,7 @@
 #include <linux/blkdev.h>
 #include <asm/uaccess.h>
 #include <asm/io.h>
+#include <linux/smp_lock.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
 #include <linux/reboot.h>
@@ -3622,7 +3623,9 @@
 			/*
 			 * Issue the command
 			 */
+			unlock_kernel();
 			mega_internal_command(adapter, LOCK_INT, &mc, pthru);
+			lock_kernel();
 
 			rval = mega_n_to_m((void __user *)arg, &mc);
 
@@ -3705,7 +3708,9 @@
 			/*
 			 * Issue the command
 			 */
+			unlock_kernel();
 			mega_internal_command(adapter, LOCK_INT, &mc, NULL);
+			lock_kernel();
 
 			rval = mega_n_to_m((void __user *)arg, &mc);
 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] 2.6.8.1 MegaRAID Driver Race
  2004-08-23 21:57 [PATCH] 2.6.8.1 MegaRAID Driver Race bradgoodman.com
@ 2004-08-23 22:16 ` Andrew Morton
  2004-08-28 19:15 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2004-08-23 22:16 UTC (permalink / raw)
  To: bradgoodman.com; +Cc: Atul.Mukker, bgoodman, linux-kernel, marcelo, torvalds

"bradgoodman.com" <bkgoodman@bradgoodman.com> wrote:
>
> [PATCH] 2.6.8.1 to LSI Logic MegaRAID Adapter - ioctl function calls 
> mega_internal_command, which uses wait_event, which calls schedule.
> This means schedule() is called while big kernel_lock is held.
> 
> Locks/Unlocks were done here because 
> 
> 1. There are a lot of return()s in the ioctl function to dodge.
> 2. mega_internal_command is also called by read and writes,
>    which don't hold big kernel_lock

Calling schedule() inside lock_kernel() is legal.

It may, however, be wrong within the context of the particular caller
because schedule() will drop the lock.  So new races might have been
introduced.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] 2.6.8.1 MegaRAID Driver Race
  2004-08-23 21:57 [PATCH] 2.6.8.1 MegaRAID Driver Race bradgoodman.com
  2004-08-23 22:16 ` Andrew Morton
@ 2004-08-28 19:15 ` Alan Cox
  1 sibling, 0 replies; 3+ messages in thread
From: Alan Cox @ 2004-08-28 19:15 UTC (permalink / raw)
  To: bradgoodman.com
  Cc: akpm, Atul.Mukker, bgoodman, Linux Kernel Mailing List,
	Marcelo Tosatti, torvalds

On Llu, 2004-08-23 at 22:57, bradgoodman.com wrote:
> [PATCH] 2.6.8.1 to LSI Logic MegaRAID Adapter - ioctl function calls 
> mega_internal_command, which uses wait_event, which calls schedule.
> This means schedule() is called while big kernel_lock is held.

This is allowed. The bkl is dropped and regained across sleeps. Its a
lock that gives "traditional unix semantics" not a normal lock.


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-08-28 20:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-23 21:57 [PATCH] 2.6.8.1 MegaRAID Driver Race bradgoodman.com
2004-08-23 22:16 ` Andrew Morton
2004-08-28 19:15 ` Alan Cox

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.