Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349004
b: refs/heads/master
c: f56c319
h: refs/heads/master
v: v3
  • Loading branch information
Tejun Heo authored and Linus Torvalds committed Jan 23, 2013
1 parent dfb0ef0 commit 6128010
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ed06ef318a7ddde3823966f808f39b515eae1862
refs/heads/master: f56c3196f251012de9b3ebaff55732a9074fdaae
27 changes: 20 additions & 7 deletions trunk/kernel/async.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,18 +86,27 @@ static atomic_t entry_count;
*/
static async_cookie_t __lowest_in_progress(struct async_domain *running)
{
async_cookie_t first_running = next_cookie; /* infinity value */
async_cookie_t first_pending = next_cookie; /* ditto */
struct async_entry *entry;

/*
* Both running and pending lists are sorted but not disjoint.
* Take the first cookies from both and return the min.
*/
if (!list_empty(&running->domain)) {
entry = list_first_entry(&running->domain, typeof(*entry), list);
return entry->cookie;
first_running = entry->cookie;
}

list_for_each_entry(entry, &async_pending, list)
if (entry->running == running)
return entry->cookie;
list_for_each_entry(entry, &async_pending, list) {
if (entry->running == running) {
first_pending = entry->cookie;
break;
}
}

return next_cookie; /* "infinity" value */
return min(first_running, first_pending);
}

static async_cookie_t lowest_in_progress(struct async_domain *running)
Expand All @@ -118,13 +127,17 @@ static void async_run_entry_fn(struct work_struct *work)
{
struct async_entry *entry =
container_of(work, struct async_entry, work);
struct async_entry *pos;
unsigned long flags;
ktime_t uninitialized_var(calltime), delta, rettime;
struct async_domain *running = entry->running;

/* 1) move self to the running queue */
/* 1) move self to the running queue, make sure it stays sorted */
spin_lock_irqsave(&async_lock, flags);
list_move_tail(&entry->list, &running->domain);
list_for_each_entry_reverse(pos, &running->domain, list)
if (entry->cookie < pos->cookie)
break;
list_move_tail(&entry->list, &pos->list);
spin_unlock_irqrestore(&async_lock, flags);

/* 2) run (and print duration) */
Expand Down

0 comments on commit 6128010

Please sign in to comment.