Messages in this thread Patch in this message | | | From | Tejun Heo <> | Subject | [PATCH 1/5] workqueue: implement workqueue_on_rescuer() | Date | Mon, 6 Sep 2010 14:46:18 +0200 |
| |
workqueue_on_rescuer() tests whether the caller is running on the rescuer of the specified workqueue.
Signed-off-by: Tejun Heo <tj@kernel.org> --- include/linux/workqueue.h | 1 + kernel/workqueue.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h index f11100f..c988063 100644 --- a/include/linux/workqueue.h +++ b/include/linux/workqueue.h @@ -339,6 +339,7 @@ extern int cancel_work_sync(struct work_struct *work); extern void workqueue_set_max_active(struct workqueue_struct *wq, int max_active); extern bool workqueue_congested(unsigned int cpu, struct workqueue_struct *wq); +extern bool workqueue_on_rescuer(struct workqueue_struct *wq); extern unsigned int work_cpu(struct work_struct *work); extern unsigned int work_busy(struct work_struct *work); diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 727f24e..a91e1ca 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c @@ -2941,6 +2941,21 @@ bool workqueue_congested(unsigned int cpu, struct workqueue_struct *wq) EXPORT_SYMBOL_GPL(workqueue_congested); /** + * workqueue_on_rescuer - test whether executing on the rescuer + * @wq: target workqueue + * + * Test whether the caller is currently executing on @wq's rescuer. + * + * RETURNS: + * %true if executing on @wq's rescuer, %false otherwise. + */ +bool workqueue_on_rescuer(struct workqueue_struct *wq) +{ + return wq->rescuer && current == wq->rescuer->task; +} +EXPORT_SYMBOL_GPL(workqueue_on_rescuer); + +/** * work_cpu - return the last known associated cpu for @work * @work: the work of interest * -- 1.7.1
| |