Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 350294
b: refs/heads/master
c: 60c057b
h: refs/heads/master
v: v3
  • Loading branch information
Lai Jiangshan authored and Tejun Heo committed Feb 7, 2013
1 parent 8398f82 commit c252faa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 30 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: 038366c5cf23ae737b9f72169dd8ade2d105755b
refs/heads/master: 60c057bca22285efefbba033624763a778f243bf
3 changes: 3 additions & 0 deletions trunk/include/linux/workqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ struct work_struct {
struct delayed_work {
struct work_struct work;
struct timer_list timer;

/* target workqueue and CPU ->timer uses to queue ->work */
struct workqueue_struct *wq;
int cpu;
};

Expand Down
32 changes: 3 additions & 29 deletions trunk/kernel/workqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -1339,10 +1339,9 @@ EXPORT_SYMBOL_GPL(queue_work);
void delayed_work_timer_fn(unsigned long __data)
{
struct delayed_work *dwork = (struct delayed_work *)__data;
struct cpu_workqueue_struct *cwq = get_work_cwq(&dwork->work);

/* should have been called from irqsafe timer with irq already off */
__queue_work(dwork->cpu, cwq->wq, &dwork->work);
__queue_work(dwork->cpu, dwork->wq, &dwork->work);
}
EXPORT_SYMBOL_GPL(delayed_work_timer_fn);

Expand All @@ -1351,7 +1350,6 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
{
struct timer_list *timer = &dwork->timer;
struct work_struct *work = &dwork->work;
unsigned int lcpu;

WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
timer->data != (unsigned long)dwork);
Expand All @@ -1371,30 +1369,7 @@ static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,

timer_stats_timer_set_start_info(&dwork->timer);

/*
* This stores cwq for the moment, for the timer_fn. Note that the
* work's pool is preserved to allow reentrance detection for
* delayed works.
*/
if (!(wq->flags & WQ_UNBOUND)) {
struct worker_pool *pool = get_work_pool(work);

/*
* If we cannot get the last pool from @work directly,
* select the last CPU such that it avoids unnecessarily
* triggering non-reentrancy check in __queue_work().
*/
lcpu = cpu;
if (pool)
lcpu = pool->cpu;
if (lcpu == WORK_CPU_UNBOUND)
lcpu = raw_smp_processor_id();
} else {
lcpu = WORK_CPU_UNBOUND;
}

set_work_cwq(work, get_cwq(lcpu, wq), 0);

dwork->wq = wq;
dwork->cpu = cpu;
timer->expires = jiffies + delay;

Expand Down Expand Up @@ -2944,8 +2919,7 @@ bool flush_delayed_work(struct delayed_work *dwork)
{
local_irq_disable();
if (del_timer_sync(&dwork->timer))
__queue_work(dwork->cpu,
get_work_cwq(&dwork->work)->wq, &dwork->work);
__queue_work(dwork->cpu, dwork->wq, &dwork->work);
local_irq_enable();
return flush_work(&dwork->work);
}
Expand Down

0 comments on commit c252faa

Please sign in to comment.