All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] async: fix __lowest_in_progress()
@ 2009-01-12 10:16 Arjan van de Ven
  0 siblings, 0 replies; 4+ messages in thread
From: Arjan van de Ven @ 2009-01-12 10:16 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

>From 24bafdeb8a42e2e43a1928ca72159e6ff90cfe85 Mon Sep 17 00:00:00 2001
From: Arjan van de Ven <arjan@linux.intel.com>
Date: Sun, 11 Jan 2009 15:35:01 +0000
Subject: [PATCH] async: fix __lowest_in_progress()

At 37000 feet somewhere near Greenland I woke up from a half-sleep with the 
realisation that __lowest_in_progress() is buggy. After landing I checked 
and there were indeed 2 problems with it; this patch fixes both:
* The order of the list checks was wrong
* The locking was not correct.

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
---
 kernel/async.c |   21 ++++++++++++++++-----
 1 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/kernel/async.c b/kernel/async.c
index f286e9f..608b32b 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -90,12 +90,12 @@ extern int initcall_debug;
 static async_cookie_t  __lowest_in_progress(struct list_head *running)
 {
 	struct async_entry *entry;
-	if (!list_empty(&async_pending)) {
-		entry = list_first_entry(&async_pending,
+	if (!list_empty(running)) {
+		entry = list_first_entry(running,
 			struct async_entry, list);
 		return entry->cookie;
-	} else if (!list_empty(running)) {
-		entry = list_first_entry(running,
+	} else if (!list_empty(&async_pending)) {
+		entry = list_first_entry(&async_pending,
 			struct async_entry, list);
 		return entry->cookie;
 	} else {
@@ -104,6 +104,17 @@ static async_cookie_t  __lowest_in_progress(struct list_head *running)
 	}
 
 }
+
+static async_cookie_t  lowest_in_progress(struct list_head *running)
+{
+	unsigned long flags;
+	async_cookie_t ret;
+
+	spin_lock_irqsave(&async_lock, flags);
+	ret = __lowest_in_progress(running);
+	spin_unlock_irqrestore(&async_lock, flags);
+	return ret;
+}
 /*
  * pick the first pending entry and run it
  */
@@ -229,7 +240,7 @@ void async_synchronize_cookie_special(async_cookie_t cookie, struct list_head *r
 		starttime = ktime_get();
 	}
 
-	wait_event(async_done, __lowest_in_progress(running) >= cookie);
+	wait_event(async_done, lowest_in_progress(running) >= cookie);
 
 	if (initcall_debug && system_state == SYSTEM_BOOTING) {
 		endtime = ktime_get();
-- 
1.6.0.6



-- 
Arjan van de Ven 	Intel Open Source Technology Centre
For development, discussion and tips for power savings, 
visit http://www.lesswatts.org

^ permalink raw reply related	[flat|nested] 4+ messages in thread
* Re: USB device cannot be reconnected and khubd "blocked for more than 120 seconds"
@ 2013-01-13 12:09 Alex Riesen
  2013-01-13 16:56 ` Alan Stern
  0 siblings, 1 reply; 4+ messages in thread
From: Alex Riesen @ 2013-01-13 12:09 UTC (permalink / raw)
  To: Alan Stern, Jens Axboe; +Cc: linux-usb, Linux Kernel Mailing List

On Sat, Jan 12, 2013 at 11:52 PM, Alan Stern <stern@rowland.harvard.edu> wrote:
> On Sat, 12 Jan 2013, Alex Riesen wrote:
>> Now, who would be interested to handle this kind of misconfiguration ...
>
> So the whole thing was a false alarm?

Yes, almost. What about khubd hanging when machine is shutdown?

> Maybe you should report to the block-layer maintainers that it's
> possible to mess up the system by building an elevator as a module.
> That sounds like the sort of thing they'd be interested to hear.

Hi Jens,

may I point you at this problem report:

http://thread.gmane.org/gmane.linux.kernel/1420814

It is surely a misconfiguration on my part (the used io scheduler
configured as a module), but the behavior is somewhat problematic
anyway: at least in this case USB storage is essentially locked up.

Regards,
Alex

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

end of thread, other threads:[~2013-01-17 18:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-01-12 10:16 [PATCH] async: fix __lowest_in_progress() Arjan van de Ven
2013-01-13 12:09 USB device cannot be reconnected and khubd "blocked for more than 120 seconds" Alex Riesen
2013-01-13 16:56 ` Alan Stern
2013-01-13 17:42   ` Alex Riesen
2013-01-14  3:47     ` Ming Lei
2013-01-14  7:15       ` Ming Lei
2013-01-14 17:30         ` Linus Torvalds
2013-01-15  1:53           ` Ming Lei
2013-01-15  6:23             ` Ming Lei
2013-01-15 17:36               ` Linus Torvalds
2013-01-15 18:32                 ` Tejun Heo
2013-01-16 17:19                   ` [PATCH] async: fix __lowest_in_progress() Tejun Heo
2013-01-17 18:16                     ` Linus Torvalds
2013-01-17 18:50                       ` Tejun Heo

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.