diff options
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r-- | kernel/workqueue.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index cfb8aa567e17..c276dec75ea4 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
@@ -82,6 +82,7 @@ struct worker { | |||
82 | }; | 82 | }; |
83 | 83 | ||
84 | struct work_struct *current_work; /* L: work being processed */ | 84 | struct work_struct *current_work; /* L: work being processed */ |
85 | struct cpu_workqueue_struct *current_cwq; /* L: current_work's cwq */ | ||
85 | struct list_head scheduled; /* L: scheduled works */ | 86 | struct list_head scheduled; /* L: scheduled works */ |
86 | struct task_struct *task; /* I: worker task */ | 87 | struct task_struct *task; /* I: worker task */ |
87 | struct global_cwq *gcwq; /* I: the associated gcwq */ | 88 | struct global_cwq *gcwq; /* I: the associated gcwq */ |
@@ -373,6 +374,59 @@ static struct hlist_head *busy_worker_head(struct global_cwq *gcwq, | |||
373 | } | 374 | } |
374 | 375 | ||
375 | /** | 376 | /** |
377 | * __find_worker_executing_work - find worker which is executing a work | ||
378 | * @gcwq: gcwq of interest | ||
379 | * @bwh: hash head as returned by busy_worker_head() | ||
380 | * @work: work to find worker for | ||
381 | * | ||
382 | * Find a worker which is executing @work on @gcwq. @bwh should be | ||
383 | * the hash head obtained by calling busy_worker_head() with the same | ||
384 | * work. | ||
385 | * | ||
386 | * CONTEXT: | ||
387 | * spin_lock_irq(gcwq->lock). | ||
388 | * | ||
389 | * RETURNS: | ||
390 | * Pointer to worker which is executing @work if found, NULL | ||
391 | * otherwise. | ||
392 | */ | ||
393 | static struct worker *__find_worker_executing_work(struct global_cwq *gcwq, | ||
394 | struct hlist_head *bwh, | ||
395 | struct work_struct *work) | ||
396 | { | ||
397 | struct worker *worker; | ||
398 | struct hlist_node *tmp; | ||
399 | |||
400 | hlist_for_each_entry(worker, tmp, bwh, hentry) | ||
401 | if (worker->current_work == work) | ||
402 | return worker; | ||
403 | return NULL; | ||
404 | } | ||
405 | |||
406 | /** | ||
407 | * find_worker_executing_work - find worker which is executing a work | ||
408 | * @gcwq: gcwq of interest | ||
409 | * @work: work to find worker for | ||
410 | * | ||
411 | * Find a worker which is executing @work on @gcwq. This function is | ||
412 | * identical to __find_worker_executing_work() except that this | ||
413 | * function calculates @bwh itself. | ||
414 | * | ||
415 | * CONTEXT: | ||
416 | * spin_lock_irq(gcwq->lock). | ||
417 | * | ||
418 | * RETURNS: | ||
419 | * Pointer to worker which is executing @work if found, NULL | ||
420 | * otherwise. | ||
421 | */ | ||
422 | static struct worker *find_worker_executing_work(struct global_cwq *gcwq, | ||
423 | struct work_struct *work) | ||
424 | { | ||
425 | return __find_worker_executing_work(gcwq, busy_worker_head(gcwq, work), | ||
426 | work); | ||
427 | } | ||
428 | |||
429 | /** | ||
376 | * insert_work - insert a work into cwq | 430 | * insert_work - insert a work into cwq |
377 | * @cwq: cwq @work belongs to | 431 | * @cwq: cwq @work belongs to |
378 | * @work: work to insert | 432 | * @work: work to insert |
@@ -914,6 +968,7 @@ static void process_one_work(struct worker *worker, struct work_struct *work) | |||
914 | debug_work_deactivate(work); | 968 | debug_work_deactivate(work); |
915 | hlist_add_head(&worker->hentry, bwh); | 969 | hlist_add_head(&worker->hentry, bwh); |
916 | worker->current_work = work; | 970 | worker->current_work = work; |
971 | worker->current_cwq = cwq; | ||
917 | work_color = get_work_color(work); | 972 | work_color = get_work_color(work); |
918 | list_del_init(&work->entry); | 973 | list_del_init(&work->entry); |
919 | 974 | ||
@@ -942,6 +997,7 @@ static void process_one_work(struct worker *worker, struct work_struct *work) | |||
942 | /* we're done with it, release */ | 997 | /* we're done with it, release */ |
943 | hlist_del_init(&worker->hentry); | 998 | hlist_del_init(&worker->hentry); |
944 | worker->current_work = NULL; | 999 | worker->current_work = NULL; |
1000 | worker->current_cwq = NULL; | ||
945 | cwq_dec_nr_in_flight(cwq, work_color); | 1001 | cwq_dec_nr_in_flight(cwq, work_color); |
946 | } | 1002 | } |
947 | 1003 | ||