Re: [PATCH 2/2] tracing: Keep pid and comm[] in the same structure
From: David Laight <hidden>
Date: 2026-07-01 12:04:08
Also in:
lkml
On Wed, 1 Jul 2026 06:38:22 -0400 Steven Rostedt [off-list ref] wrote:
On Wed, 1 Jul 2026 11:04:07 +0100 David Laight [off-list ref] wrote:quoted
I thought it was just used to do a pid->string lookup when you run 'cat trace'. But then I found the code that lets userspace read the table.... I guess the latter is used by the userspace code that reads the raw trace buffer.Yes, trace-cmd uses it.
...
quoted
The userspace code could probably be given comm[] for all the running processes and those that exited while tracing_on() set. (I didn't see anything that would clear the table when the trace buffer was cleared.)Well, that would break trace-cmd. As reading the raw buffers clears the trace, and trace-cmd reads the saved_cmdlines file *after* it reads the trace, as during the trace it gets populated.
So you'd need to clear it when tracing is enabled after the buffer is cleared. Just a matter of getting the timing right. If trace-cmd is currently given all 6000 entries (if you've run tracing for long enough), then giving it all the active processes isn't going to be any more of a problem. So you could just save comm[] in the process exit path when the trace buffer is non-empty, or better those started before tracing was last stopped. You'd need to give trace-cmd the active ones first and delete the entry from the cache because the pid might have been reused. All just needs some coding, testing, and fixing of corner cases. -- David
-- Steve