>From 5a4876f8d06451b2fd41f617b773488030772362 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 7 Feb 2008 19:14:05 +0100 Subject: [PATCH] Add interface for queuing work on a specific CPU Signed-off-by: Jens Axboe --- include/linux/workqueue.h | 2 ++ kernel/workqueue.c | 33 ++++++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index 7f28c32..53c45c4 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -179,6 +179,8 @@ __create_workqueue_key(const char *name, int singlethread, extern void destroy_workqueue(struct workqueue_struct *wq); extern int FASTCALL(queue_work(struct workqueue_struct *wq, struct work_struct *work)); +extern int queue_work_on_cpu(struct workqueue_struct *wq, + struct work_struct *work, int cpu); extern int FASTCALL(queue_delayed_work(struct workqueue_struct *wq, struct delayed_work *work, unsigned long delay)); extern int queue_delayed_work_on(int cpu, struct workqueue_struct *wq, diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 52db48e..96dd90e 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -152,25 +152,44 @@ static void __queue_work(struct cpu_workqueue_struct *cwq, } /** - * queue_work - queue work on a workqueue + * queue_work_on_cpu - queue work on a workqueue on a specific CPU * @wq: workqueue to use * @work: work to queue + * @cpu: cpu to queue the work on * * Returns 0 if @work was already on a queue, non-zero otherwise. - * - * We queue the work to the CPU it was submitted, but there is no - * guarantee that it will be processed by that CPU. */ -int fastcall queue_work(struct workqueue_struct *wq, struct work_struct *work) +int queue_work_on_cpu(struct workqueue_struct *wq, struct work_struct *work, + int cpu) { int ret = 0; if (!test_and_set_bit(WORK_STRUCT_PENDING, work_data_bits(work))) { BUG_ON(!list_empty(&work->entry)); - __queue_work(wq_per_cpu(wq, get_cpu()), work); - put_cpu(); + __queue_work(wq_per_cpu(wq, cpu), work); ret = 1; } + + return ret; +} +EXPORT_SYMBOL_GPL(queue_work_on_cpu); + +/** + * queue_work - queue work on a workqueue + * @wq: workqueue to use + * @work: work to queue + * + * Returns 0 if @work was already on a queue, non-zero otherwise. + * + * We queue the work to the CPU it was submitted, but there is no + * guarantee that it will be processed by that CPU. + */ +int fastcall queue_work(struct workqueue_struct *wq, struct work_struct *work) +{ + int ret; + + ret = queue_work_on_cpu(wq, work, get_cpu()); + put_cpu(); return ret; } EXPORT_SYMBOL_GPL(queue_work); -- 1.5.4.rc5.5.gab98