Skip to content

Commit

Permalink
async: make sure independent async domains can't accidentally entangle
Browse files Browse the repository at this point in the history
The problem occurs when async_synchronize_full_domain() is called when
the async_pending list is not empty.  This will cause lowest_running()
to return the cookie of the first entry on the async_pending list, which
might be nothing at all to do with the domain being asked for and thus
cause the domain synchronization to wait for an unrelated domain.   This
can cause a deadlock if domain synchronization is used from one domain
to wait for another.

Fix by running over the async_pending list to see if any pending items
actually belong to our domain (and return their cookies if they do).

Signed-off-by: James Bottomley <[email protected]>
Signed-off-by: Arjan van de Ven <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
James Bottomley authored and torvalds committed May 24, 2009
1 parent 657cafa commit d5a877e
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions kernel/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,23 @@ extern int initcall_debug;
static async_cookie_t __lowest_in_progress(struct list_head *running)
{
struct async_entry *entry;
async_cookie_t ret = next_cookie; /* begin with "infinity" value */

if (!list_empty(running)) {
entry = list_first_entry(running,
struct async_entry, list);
return entry->cookie;
} else if (!list_empty(&async_pending)) {
entry = list_first_entry(&async_pending,
struct async_entry, list);
return entry->cookie;
} else {
/* nothing in progress... next_cookie is "infinity" */
return next_cookie;
ret = entry->cookie;
}

if (!list_empty(&async_pending)) {
list_for_each_entry(entry, &async_pending, list)
if (entry->running == running) {
ret = entry->cookie;
break;
}
}

return ret;
}

static async_cookie_t lowest_in_progress(struct list_head *running)
Expand Down

0 comments on commit d5a877e

Please sign in to comment.