提交 7beb2edf 编写于 作者: T Tejun Heo

workqueue: factor out __queue_delayed_work() from queue_delayed_work_on()

This is to prepare for mod_delayed_work[_on]() and doesn't cause any
functional difference.
Signed-off-by: NTejun Heo <tj@kernel.org>
上级 b5490077
...@@ -1261,32 +1261,11 @@ void delayed_work_timer_fn(unsigned long __data) ...@@ -1261,32 +1261,11 @@ void delayed_work_timer_fn(unsigned long __data)
} }
EXPORT_SYMBOL_GPL(delayed_work_timer_fn); EXPORT_SYMBOL_GPL(delayed_work_timer_fn);
/** static void __queue_delayed_work(int cpu, struct workqueue_struct *wq,
* queue_delayed_work_on - queue work on specific CPU after delay
* @cpu: CPU number to execute work on
* @wq: workqueue to use
* @dwork: work to queue
* @delay: number of jiffies to wait before queueing
*
* Returns %false if @work was already on a queue, %true otherwise. If
* @delay is zero and @dwork is idle, it will be scheduled for immediate
* execution.
*/
bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
struct delayed_work *dwork, unsigned long delay) struct delayed_work *dwork, unsigned long delay)
{ {
struct timer_list *timer = &dwork->timer; struct timer_list *timer = &dwork->timer;
struct work_struct *work = &dwork->work; struct work_struct *work = &dwork->work;
bool ret = false;
unsigned long flags;
if (!delay)
return queue_work_on(cpu, wq, &dwork->work);
/* read the comment in __queue_work() */
local_irq_save(flags);
if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) {
unsigned int lcpu; unsigned int lcpu;
WARN_ON_ONCE(timer->function != delayed_work_timer_fn || WARN_ON_ONCE(timer->function != delayed_work_timer_fn ||
...@@ -1297,9 +1276,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, ...@@ -1297,9 +1276,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
timer_stats_timer_set_start_info(&dwork->timer); timer_stats_timer_set_start_info(&dwork->timer);
/* /*
* This stores cwq for the moment, for the timer_fn. * This stores cwq for the moment, for the timer_fn. Note that the
* Note that the work's gcwq is preserved to allow * work's gcwq is preserved to allow reentrance detection for
* reentrance detection for delayed works. * delayed works.
*/ */
if (!(wq->flags & WQ_UNBOUND)) { if (!(wq->flags & WQ_UNBOUND)) {
struct global_cwq *gcwq = get_work_gcwq(work); struct global_cwq *gcwq = get_work_gcwq(work);
...@@ -1308,8 +1287,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, ...@@ -1308,8 +1287,9 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
lcpu = gcwq->cpu; lcpu = gcwq->cpu;
else else
lcpu = raw_smp_processor_id(); lcpu = raw_smp_processor_id();
} else } else {
lcpu = WORK_CPU_UNBOUND; lcpu = WORK_CPU_UNBOUND;
}
set_work_cwq(work, get_cwq(lcpu, wq), 0); set_work_cwq(work, get_cwq(lcpu, wq), 0);
...@@ -1319,6 +1299,34 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq, ...@@ -1319,6 +1299,34 @@ bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
add_timer_on(timer, cpu); add_timer_on(timer, cpu);
else else
add_timer(timer); add_timer(timer);
}
/**
* queue_delayed_work_on - queue work on specific CPU after delay
* @cpu: CPU number to execute work on
* @wq: workqueue to use
* @dwork: work to queue
* @delay: number of jiffies to wait before queueing
*
* Returns %false if @work was already on a queue, %true otherwise. If
* @delay is zero and @dwork is idle, it will be scheduled for immediate
* execution.
*/
bool queue_delayed_work_on(int cpu, struct workqueue_struct *wq,
struct delayed_work *dwork, unsigned long delay)
{
struct work_struct *work = &dwork->work;
bool ret = false;
unsigned long flags;
if (!delay)
return queue_work_on(cpu, wq, &dwork->work);
/* read the comment in __queue_work() */
local_irq_save(flags);
if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) {
__queue_delayed_work(cpu, wq, dwork, delay);
ret = true; ret = true;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册