Re: [PATCH] workqueue: show the latest function name in /proc/PID/{comm,stat,status}

From: Tejun Heo
Date: Mon May 19 2025 - 16:07:25 EST


Hello,

On Fri, May 16, 2025 at 12:44:19PM +0800, Muchun Song wrote:
...
> Monitoring tools like atop can indeed record comm of processes. When we
> encounter issues such as high CPU usage, these tools can help us identify
> the problem. For instance, if kworkers are consuming most of the CPU, we
> can use this information to pinpoint which specific function is using
> the most CPU.

You can get more detailed information with `cat /proc/KWORKER_PID/stack`.
The problem is that last_func can be stale most of the time and can be more
misleading than useful.

> Another use case is when we use the isolcpus= command line option
> to isolate CPUs, we want to make sure that no kworker threads run on
> those CPUs. But sometimes, kworkers might still get scheduled there, causing latency
> issues. By using this information, we can figure out which module's
> function ran on the CPU before and then dig into the code to see how to
> stop it from happening.

Can you explain why `cat /proc/KWORKER_PID/stack` can't be used for that? If
the worker runtime is too short to capture, you can easily use tracepoints
or bpftrace too. What are the benefits of showing last_func?

Thanks.

--
tejun