Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 327192
b: refs/heads/master
c: 3aa6249
h: refs/heads/master
v: v3
  • Loading branch information
Lai Jiangshan authored and Tejun Heo committed Sep 18, 2012
1 parent c937ad2 commit 4244a59
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 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: a5b4e57d7cc07cb28ccf16de0876a4770ae84920
refs/heads/master: 3aa62497594430ea522050b75c033f71f2c60ee6
25 changes: 22 additions & 3 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -977,17 +977,24 @@ static void move_linked_works(struct work_struct *work, struct list_head *head,
*nextp = n;
}

static void cwq_activate_first_delayed(struct cpu_workqueue_struct *cwq)
static void cwq_activate_delayed_work(struct work_struct *work)
{
struct work_struct *work = list_first_entry(&cwq->delayed_works,
struct work_struct, entry);
struct cpu_workqueue_struct *cwq = get_work_cwq(work);

trace_workqueue_activate_work(work);
move_linked_works(work, &cwq->pool->worklist, NULL);
__clear_bit(WORK_STRUCT_DELAYED_BIT, work_data_bits(work));
cwq->nr_active++;
}

static void cwq_activate_first_delayed(struct cpu_workqueue_struct *cwq)
{
struct work_struct *work = list_first_entry(&cwq->delayed_works,
struct work_struct, entry);

cwq_activate_delayed_work(work);
}

/**
* cwq_dec_nr_in_flight - decrement cwq's nr_in_flight
* @cwq: cwq of interest
Expand Down Expand Up @@ -1106,6 +1113,18 @@ static int try_to_grab_pending(struct work_struct *work, bool is_dwork,
smp_rmb();
if (gcwq == get_work_gcwq(work)) {
debug_work_deactivate(work);

/*
* A delayed work item cannot be grabbed directly
* because it might have linked NO_COLOR work items
* which, if left on the delayed_list, will confuse
* cwq->nr_active management later on and cause
* stall. Make sure the work item is activated
* before grabbing.
*/
if (*work_data_bits(work) & WORK_STRUCT_DELAYED)
cwq_activate_delayed_work(work);

list_del_init(&work->entry);
cwq_dec_nr_in_flight(get_work_cwq(work),
get_work_color(work),
Expand Down

0 comments on commit 4244a59

Please sign in to comment.