History

workqueue: Remove now redundant lock acquisitions wrt. workqueue flushes

The workqueue code added manual lock acquisition annotations to catch deadlocks. After lockdepcrossrelease was introduced, some of those became redundant, since wait_for_completion() already does the acquisition and tracking. Remove the duplicate annotations.

Byungchul Park committed 9 years ago

Commit fd1a5b01 parent a7967bc2 files · +5 −18Browse files

Showing the changes to kernel/workqueue.c (1 of 2 files). Show all

Unified · Split

kernel/workqueue.c+3−16
@@ -2497,15 +2497,8 @@ static void insert_wq_barrier(struct pool_workqueue *pwq, · 2496 unmodified lines
24972497 INIT_WORK_ONSTACK(&barr->work, wq_barrier_func);
24982498 __set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(&barr->work));
24992499
2500− /*
2501− * Explicitly init the crosslock for wq_barrier::done, make its lock
2502− * key a subkey of the corresponding work. As a result we won't
2503− * build a dependency between wq_barrier::done and unrelated work.
2504− */
2505− lockdep_init_map_crosslock((struct lockdep_map *)&barr->done.map,
2506− "(complete)wq_barr::done",
2507− target->lockdep_map.key, 1);
2508− __init_completion(&barr->done);
2500+ init_completion_map(&barr->done, &target->lockdep_map);
2501+
25092502 barr->task = current;
25102503
25112504 /*
@@ -2611,16 +2604,13 @@ void flush_workqueue(struct workqueue_struct *wq) · 99 unmodified lines
26112604 struct wq_flusher this_flusher = {
26122605 .list = LIST_HEAD_INIT(this_flusher.list),
26132606 .flush_color = -1,
2614− .done = COMPLETION_INITIALIZER_ONSTACK(this_flusher.done),
2607+ .done = COMPLETION_INITIALIZER_ONSTACK_MAP(this_flusher.done, wq->lockdep_map),
26152608 };
26162609 int next_color;
26172610
26182611 if (WARN_ON(!wq_online))
26192612 return;
26202613
2621− lock_map_acquire(&wq->lockdep_map);
2622− lock_map_release(&wq->lockdep_map);
2623−
26242614 mutex_lock(&wq->mutex);
26252615
26262616 /*
@@ -2883,9 +2873,6 @@ bool flush_work(struct work_struct *work) · 256 unmodified lines
28832873 if (WARN_ON(!wq_online))
28842874 return false;
28852875
2886− lock_map_acquire(&work->lockdep_map);
2887− lock_map_release(&work->lockdep_map);
2888−
28892876 if (start_flush_work(work, &barr)) {
28902877 wait_for_completion(&barr.done);
28912878 destroy_work_on_stack(&barr.work);