All of lore.kernel.org
 help / color / mirror / Atom feed
* bad: scheduling while atomic! (Part Deux)
@ 2003-06-15 15:07 Russell King
  2003-06-15 15:42 ` Jörn Engel
  0 siblings, 1 reply; 2+ messages in thread
From: Russell King @ 2003-06-15 15:07 UTC (permalink / raw)
  To: Linux Kernel List; +Cc: David Woodhouse

Sigh.  Another MTD deadlock, and cause of scheduling badness on UP preempt.

David, I think MTD needs an audit to ensure that no further cases exist.

static void cfi_intelext_sync (struct mtd_info *mtd)
{
        for (i=0; !ret && i<cfi->numchips; i++) {
                chip = &cfi->chips[i];

                spin_lock(chip->mutex);
                ret = get_chip(map, chip, chip->start, FL_SYNCING);
...
        }

        /* Unlock the chips again */

        for (i--; i >=0; i--) {
                chip = &cfi->chips[i];

                spin_lock(chip->mutex);
...
                spin_unlock(chip->mutex);
        }
}

-- 
Russell King (rmk@arm.linux.org.uk)                The developer of ARM Linux
             http://www.arm.linux.org.uk/personal/aboutme.html


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

* Re: bad: scheduling while atomic! (Part Deux)
  2003-06-15 15:07 bad: scheduling while atomic! (Part Deux) Russell King
@ 2003-06-15 15:42 ` Jörn Engel
  0 siblings, 0 replies; 2+ messages in thread
From: Jörn Engel @ 2003-06-15 15:42 UTC (permalink / raw)
  To: Linux Kernel List, David Woodhouse

On Sun, 15 June 2003 16:07:29 +0100, Russell King wrote:
> 
> Sigh.  Another MTD deadlock, and cause of scheduling badness on UP preempt.
> 
> David, I think MTD needs an audit to ensure that no further cases exist.

Could this be done with smatch plus some perl?  Being a lazy bastard,
I like the idea of letting the machines do the boring repetetive job.

> static void cfi_intelext_sync (struct mtd_info *mtd)
> {
>         for (i=0; !ret && i<cfi->numchips; i++) {
>                 chip = &cfi->chips[i];
> 
>                 spin_lock(chip->mutex);
>                 ret = get_chip(map, chip, chip->start, FL_SYNCING);
> ...
>         }
> 
>         /* Unlock the chips again */
> 
>         for (i--; i >=0; i--) {
>                 chip = &cfi->chips[i];
> 
>                 spin_lock(chip->mutex);
> ...
>                 spin_unlock(chip->mutex);
>         }
> }

Mindless guess of a fix part 1 & 2 below.

As an anecdote, the stupid copy of cmdset_0001, cmdset_0020, did it
right.  Interesting.

Jörn

-- 
Courage is not the absence of fear, but rather the judgement that
something else is more important than fear.
-- Ambrose Redmoon

--- linux-2.5.71/drivers/mtd/mtd_blkdevs.c~mtd_spinlocks	2003-06-15 16:05:05.000000000 +0200
+++ linux-2.5.71/drivers/mtd/mtd_blkdevs.c	2003-06-15 16:19:43.000000000 +0200
@@ -93,14 +93,13 @@
 	recalc_sigpending();
 	spin_unlock_irq(&current->sighand->siglock);
 
+	spin_lock_irq(rq->queue_lock);
 	while (!tr->blkcore_priv->exiting) {
 		struct request *req;
 		struct mtd_blktrans_dev *dev;
 		int res = 0;
 		DECLARE_WAITQUEUE(wait, current);
 
-		spin_lock_irq(rq->queue_lock);
-
 		req = elv_next_request(rq);
 
 		if (!req) {
@@ -112,6 +111,7 @@
 			schedule();
 			remove_wait_queue(&tr->blkcore_priv->thread_wq, &wait);
 
+			spin_lock_irq(rq->queue_lock);
 			continue;
 		}
 
--- linux-2.5.71/drivers/mtd/chips/cfi_cmdset_0001.c~mtd_spinlocks	2003-06-15 16:05:03.000000000 +0200
+++ linux-2.5.71/drivers/mtd/chips/cfi_cmdset_0001.c	2003-06-15 17:33:43.000000000 +0200
@@ -1423,6 +1423,7 @@
 			 * with the chip now anyway.
 			 */
 		}
+		spin_unlock(chip->mutex);
 	}
 
 	/* Unlock the chips again */

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

end of thread, other threads:[~2003-06-15 15:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-06-15 15:07 bad: scheduling while atomic! (Part Deux) Russell King
2003-06-15 15:42 ` Jörn Engel

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.