Linux Trace Kernel
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: "Masami Hiramatsu" <mhiramat@kernel.org>,
	"Mathieu Desnoyers" <mathieu.desnoyers@efficios.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	"Michal Koutný" <mkoutny@suse.com>
Subject: Re: [PATCH 2/2] tracing: Keep pid and comm[] in the same structure
Date: Wed, 1 Jul 2026 11:04:07 +0100	[thread overview]
Message-ID: <20260701110407.31f7b6ca@pumpkin> (raw)
In-Reply-To: <20260630150348.149e318c@gandalf.local.home>

On Tue, 30 Jun 2026 15:03:48 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:

> On Tue, 30 Jun 2026 11:01:56 +0100
> David Laight <david.laight.linux@gmail.com> 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	other threads:[~2026-07-01 10:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 21:23 [PATCH rfc 0/2] Improvements to ftrace comm[] handling David Laight
2026-06-26 21:23 ` [PATCH 1/2] tracing: Embed 'char comm[16]' in a structure David Laight
2026-06-29 20:26   ` Steven Rostedt
2026-06-30  9:26     ` David Laight
2026-06-26 21:23 ` [PATCH 2/2] tracing: Keep pid and comm[] in the same structure David Laight
2026-06-29 20:49   ` Steven Rostedt
2026-06-30 10:01     ` David Laight
2026-06-30 19:03       ` Steven Rostedt
2026-07-01 10:04         ` David Laight [this message]
2026-07-01 10:38           ` Steven Rostedt
2026-07-01 12:04             ` David Laight
2026-07-01 12:23               ` Steven Rostedt
2026-07-01 16:52                 ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260701110407.31f7b6ca@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mathieu.desnoyers@efficios.com \
    --cc=mhiramat@kernel.org \
    --cc=mkoutny@suse.com \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox