Pull workqueue updates from Tejun Heo: "Fix statistic update race condition and a couple documentation updates" * tag 'wq-for-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq: workqueue: fix typo in comment workqueue: Fix race condition in wq->stats incrementation workqueue: Better document teardown for delayed_work
Showing the changes to kernel/workqueue.c (1 of 2 files). Show all
Unified · Split
| @@ -3241,7 +3241,7 @@ __acquires(&pool->lock) · 3240 unmodified lines | ||
| 3241 | 3241 | * point will only record its address. |
| 3242 | 3242 | */ |
| 3243 | 3243 | trace_workqueue_execute_end(work, worker->current_func); |
| 3244 | − pwq->stats[PWQ_STAT_COMPLETED]++; | |
| 3244 | + | |
| 3245 | 3245 | lock_map_release(&lockdep_map); |
| 3246 | 3246 | if (!bh_draining) |
| 3247 | 3247 | lock_map_release(pwq->wq->lockdep_map); |
| @@ -3272,6 +3272,8 @@ __acquires(&pool->lock) · 24 unmodified lines | ||
| 3272 | 3272 | |
| 3273 | 3273 | raw_spin_lock_irq(&pool->lock); |
| 3274 | 3274 | |
| 3275 | + pwq->stats[PWQ_STAT_COMPLETED]++; | |
| 3276 | + | |
| 3275 | 3277 | /* |
| 3276 | 3278 | * In addition to %WQ_CPU_INTENSIVE, @worker may also have been marked |
| 3277 | 3279 | * CPU intensive by wq_worker_tick() if @work hogged CPU longer than |
| @@ -5837,6 +5839,17 @@ static bool pwq_busy(struct pool_workqueue *pwq) · 2559 unmodified lines | ||
| 5837 | 5839 | * @wq: target workqueue |
| 5838 | 5840 | * |
| 5839 | 5841 | * Safely destroy a workqueue. All work currently pending will be done first. |
| 5842 | + * | |
| 5843 | + * This function does NOT guarantee that non-pending work that has been | |
| 5844 | + * submitted with queue_delayed_work() and similar functions will be done | |
| 5845 | + * before destroying the workqueue. The fundamental problem is that, currently, | |
| 5846 | + * the workqueue has no way of accessing non-pending delayed_work. delayed_work | |
| 5847 | + * is only linked on the timer-side. All delayed_work must, therefore, be | |
| 5848 | + * canceled before calling this function. | |
| 5849 | + * | |
| 5850 | + * TODO: It would be better if the problem described above wouldn't exist and | |
| 5851 | + * destroy_workqueue() would cleanly cancel all pending and non-pending | |
| 5852 | + * delayed_work. | |
| 5840 | 5853 | */ |
| 5841 | 5854 | void destroy_workqueue(struct workqueue_struct *wq) |
| 5842 | 5855 | { |