workqueue: Skip non-freezable workqueues in freeze and thaw
PATCH 1/1 workqueue: Skip non-freezable workqueues in freeze and thaw
In wq_adjust_max_active(), non-freezable workqueues always keep saved_max_active and saved_min_active, so updating them during freeze and thaw is a no-op. However, both freeze and thaw acquire mutexes and adjust max_active for every wq on the wq list, which is extra work and could increase contention.
Skip workqueues without WQ_FREEZABLE in freeze and thaw.
On a v7.3 Pixel 9 device, this consistently reduces thaw_processes latency during system suspend by 4-5% (~0.7ms).
Signed-off-by Samuel Wu <[email protected]>
--- kernel/workqueue.c | 4 ++++ 1 file changed, 4 insertions(+)
kernel/workqueue.c +4 -0
@@ -7370,6 +7370,8 @@ void freeze_workqueues_begin(void) workqueue_freezing = true;list_for_each_entry (wq, &workqueues, list) { +if (!(wq->flags &WQ_FREEZABLE )) +continue ;mutex_lock (&wq->mutex);wq_adjust_max_active (wq);mutex_unlock (&wq->mutex);
@@ -7446,6 +7448,8 @@ void thaw_workqueues(void)/* restore max_active and repopulate worklist */ list_for_each_entry (wq, &workqueues, list) { +if (!(wq->flags &WQ_FREEZABLE )) +continue ;mutex_lock (&wq->mutex);wq_adjust_max_active (wq);mutex_unlock (&wq->mutex);
Signature · 1 line
2.56.0.679.gc527c65306-goog
Applied to wq/for-7.5.
Thanks.
--
tejun