Re: [PATCH 7/7] workqueue: Track and monitor per-workqueue CPU time usage

From: Peter Zijlstra
Date: Thu May 11 2023 - 17:11:48 EST


On Thu, May 11, 2023 at 08:19:31AM -1000, Tejun Heo wrote:
> Now that wq_worker_tick() is there, we can easily track the rough CPU time
> consumption of each workqueue by charging the whole tick whenever a tick
> hits an active workqueue. While not super accurate, it provides reasonable
> visibility into the workqueues that consume a lot of CPU cycles.
> wq_monitor.py is updated to report the per-workqueue CPU times.

I'm utterly failing to read that dragon thing (or possibly snake, but I
can typically sorta make out what it intends to do).

However, while you don't have preempt-out, you still have sched-out
through wq_worker_sleeping(), so you should be able to compute the time
spend on the workqueue by past worker runs -- fully accurate.

Then you only need to add the time since sched-in of any current worker
and you have a complete picture of time spend on the workqueue, no
approximation needed.

Or am I completely missing the point?