On Tue, 30 Jun 2026 15:03:48 -0400
Steven Rostedt <[email protected]> wrote:

> On Tue, 30 Jun 2026 11:01:56 +0100
> David Laight <[email protected]> wrote:
> 
> > > It's been a long time since I worked on this, but IIRC, it was to keep
> > > the pressure down on the TLB when tracing. It updates at every
> > > sched_switch that has a trace event occurring so, I likely used normal
> > > pages which are part of the huge pages the kernel sets up and doesn't
> > > affect the TLB as much. vmalloc does have impact on the TLB pressure,
> > > and tracing should always try to avoid that.    
> > 
> > Isn't this a cache so that the pid numbers can be converted to strings
> > when the trace is read out after the actual process has exited?
> > That does mean that cache doesn't need to be updated on every trace
> > request - it might be enough to just save on process exit and lookup the
> > pid itself for running processes (the whole thing relies on pids not
> > being reused).  
> 
> Yes it's a cache but it only gets filled when needed. That is, after a
> trace event occurred. Tracing is very commonly used with filtering, where
> events can be seldom triggered. What is in the saved_cmdlines file should
> only be tasks that were running when a trace occurred.
> 
> Now what we could do is add a flag to the task struct and only set that
> when tracing happens. Only tasks that exit would be saved in this array.
> The other tasks could be queried via iterating the tasks and reporting any
> task with this bit set.

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.
(I found some instructions that did it that way, the output was unparseable
when tracing things that are happening on multiple cpu.)
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.)

I'll try to remember to look at this when I get home.
(I've a pi-5 with me, not doing kernel builds on it...)

        David


Reply via email to