aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArjan van de Ven <arjan@linux.intel.com>2009-01-11 10:35:01 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2009-01-12 19:39:58 -0500
commit37a76bd4f1b716949fc38a6842e89f0ccb8384d0 (patch)
tree6537cab6fb0e1a9508d34ca95b25808866bf04af
parentd32ad102c6d748b510fd89f1af4232eac1be8732 (diff)
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--kernel/async.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/kernel/async.c b/kernel/async.c
index f286e9f2b736..608b32b42812 100644
--- a/kernel/async.c
+++ b/kernel/async.c
@@ -90,12 +90,12 @@ extern int initcall_debug;
90static async_cookie_t __lowest_in_progress(struct list_head *running) 90static async_cookie_t __lowest_in_progress(struct list_head *running)
91{ 91{
92 struct async_entry *entry; 92 struct async_entry *entry;
93 if (!list_empty(&async_pending)) { 93 if (!list_empty(running)) {
94 entry = list_first_entry(&async_pending, 94 entry = list_first_entry(running,
95 struct async_entry, list); 95 struct async_entry, list);
96 return entry->cookie; 96 return entry->cookie;
97 } else if (!list_empty(running)) { 97 } else if (!list_empty(&async_pending)) {
98 entry = list_first_entry(running, 98 entry = list_first_entry(&async_pending,
99 struct async_entry, list); 99 struct async_entry, list);
100 return entry->cookie; 100 return entry->cookie;
101 } else { 101 } else {
@@ -104,6 +104,17 @@ static async_cookie_t __lowest_in_progress(struct list_head *running)
104 } 104 }
105 105
106} 106}
107
108static async_cookie_t lowest_in_progress(struct list_head *running)
109{
110 unsigned long flags;
111 async_cookie_t ret;
112
113 spin_lock_irqsave(&async_lock, flags);
114 ret = __lowest_in_progress(running);
115 spin_unlock_irqrestore(&async_lock, flags);
116 return ret;
117}
107/* 118/*
108 * pick the first pending entry and run it 119 * pick the first pending entry and run it
109 */ 120 */
@@ -229,7 +240,7 @@ void async_synchronize_cookie_special(async_cookie_t cookie, struct list_head *r
229 starttime = ktime_get(); 240 starttime = ktime_get();
230 } 241 }
231 242
232 wait_event(async_done, __lowest_in_progress(running) >= cookie); 243 wait_event(async_done, lowest_in_progress(running) >= cookie);
233 244
234 if (initcall_debug && system_state == SYSTEM_BOOTING) { 245 if (initcall_debug && system_state == SYSTEM_BOOTING) {
235 endtime = ktime_get(); 246 endtime = ktime_get();