workqueue: Changes for v6.16

Fix statistic update race condition and a couple documentation updates.
 -----BEGIN PGP SIGNATURE-----
 
 iIQEABYKACwWIQTfIjM1kS57o3GsC/uxYfJx3gVYGQUCaDYPDw4cdGpAa2VybmVs
 Lm9yZwAKCRCxYfJx3gVYGdczAQDbp6wxE64DNfdVvEss07dHisEYobJVb5ojHCl6
 FkTYsQEAz/WtB5mwh5ohhemDKhOuG6PZuHqjuMGFCndpfxyQQQg=
 =WNPk
 -----END PGP SIGNATURE-----

Merge tag 'wq-for-6.16' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq

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
This commit is contained in:
Linus Torvalds 2025-05-27 20:49:06 -07:00
commit 91ad250cbe
2 changed files with 15 additions and 2 deletions

View File

@ -480,7 +480,7 @@ void workqueue_softirq_dead(unsigned int cpu);
* executing at most one work item for the workqueue.
*
* For unbound workqueues, @max_active limits the number of in-flight work items
* for the whole system. e.g. @max_active of 16 indicates that that there can be
* for the whole system. e.g. @max_active of 16 indicates that there can be
* at most 16 work items executing for the workqueue in the whole system.
*
* As sharing the same active counter for an unbound workqueue across multiple

View File

@ -3241,7 +3241,7 @@ __acquires(&pool->lock)
* point will only record its address.
*/
trace_workqueue_execute_end(work, worker->current_func);
pwq->stats[PWQ_STAT_COMPLETED]++;
lock_map_release(&lockdep_map);
if (!bh_draining)
lock_map_release(pwq->wq->lockdep_map);
@ -3272,6 +3272,8 @@ __acquires(&pool->lock)
raw_spin_lock_irq(&pool->lock);
pwq->stats[PWQ_STAT_COMPLETED]++;
/*
* In addition to %WQ_CPU_INTENSIVE, @worker may also have been marked
* CPU intensive by wq_worker_tick() if @work hogged CPU longer than
@ -5837,6 +5839,17 @@ static bool pwq_busy(struct pool_workqueue *pwq)
* @wq: target workqueue
*
* Safely destroy a workqueue. All work currently pending will be done first.
*
* This function does NOT guarantee that non-pending work that has been
* submitted with queue_delayed_work() and similar functions will be done
* before destroying the workqueue. The fundamental problem is that, currently,
* the workqueue has no way of accessing non-pending delayed_work. delayed_work
* is only linked on the timer-side. All delayed_work must, therefore, be
* canceled before calling this function.
*
* TODO: It would be better if the problem described above wouldn't exist and
* destroy_workqueue() would cleanly cancel all pending and non-pending
* delayed_work.
*/
void destroy_workqueue(struct workqueue_struct *wq)
{