Linux Documentation
 help / color / mirror / Atom feed
* [RFC PATCH 0/4] ftrace: Add task comm filtering for function tracing
@ 2026-08-30 11:07 hu.shengming
  2026-08-30 11:09 ` [RFC PATCH 1/4] ftrace: Generalize function task filter names hu.shengming
                   ` (5 more replies)
  0 siblings, 6 replies; 11+ messages in thread
From: hu.shengming @ 2026-08-30 11:07 UTC (permalink / raw)
  To: rostedt, mhiramat
  Cc: mathieu.desnoyers, mark.rutland, corbet, skhan, rdunlap,
	linux-kernel, linux-trace-kernel, linux-doc, ran.xiaokai,
	xu.xin16, zhang.run

Hi Steven and Masami,

This series adds two comm-based task filters for the function and
function_graph tracers:

  set_ftrace_comm
  set_ftrace_notrace_comm

Function tracing currently supports selecting tasks by PID. This makes
it difficult to configure tracing before a service starts, because it
does not have a PID yet. It is also inconvenient to keep tracing the
same service across restarts, as its PID may change. This use case was
suggested by Xuxin, a KSM reviewer.

The new filters match task comm names exactly. When both PID and comm 
include filters are active, a task must match both to be traced. A
match in either the PID or comm notrace filter excludes the task.

To avoid string matching in the function tracing fast path, the filters
are evaluated when a task is scheduled in. The result is stored in the
existing per-CPU cache used by PID filtering. Changing a filter refreshes
the cached result for currently running tasks. If a task's comm changes,
the new name is used the next time the task is scheduled in.

The first two patches prepare the existing PID-filtering infrastructure
by using general task-filter names and centralizing sched_switch probe
registration and per-CPU cache updates. The third patch adds the comm
filters, and the final patch documents their interface and interaction
with PID filters.

This is an RFC intended to discuss whether comm-based task filtering is
a useful direction for function tracing and whether this interface would
be suitable for eventual upstream inclusion. Additional selftests are
planned for the next revision. Feedback on the overall approach and
interface would be greatly appreciated.

Thanks,
Shengming

Shengming Hu (4):
  ftrace: Generalize function task filter names
  ftrace: Centralize task filter state updates
  ftrace: Add exact task comm filtering
  Documentation/ftrace: Document function comm filters

 Documentation/trace/ftrace.rst |  31 +++
 include/linux/ftrace.h         |   4 +-
 kernel/trace/Makefile          |   1 +
 kernel/trace/comm_list.c       | 314 +++++++++++++++++++++++++
 kernel/trace/comm_list.h       |  17 ++
 kernel/trace/fgraph.c          |   4 +-
 kernel/trace/ftrace.c          | 402 ++++++++++++++++++++++++++++++---
 kernel/trace/trace.c           |   5 +
 kernel/trace/trace.h           |  34 ++-
 kernel/trace/trace_events.c    |  16 +-
 kernel/trace/trace_functions.c |   2 +-
 kernel/trace/trace_pid.c       |   8 +-
 12 files changed, 791 insertions(+), 47 deletions(-)
 create mode 100644 kernel/trace/comm_list.c
 create mode 100644 kernel/trace/comm_list.h

-- 
2.25.1

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-03  1:03 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-30 11:07 [RFC PATCH 0/4] ftrace: Add task comm filtering for function tracing hu.shengming
2026-08-30 11:09 ` [RFC PATCH 1/4] ftrace: Generalize function task filter names hu.shengming
2026-08-30 11:10 ` ​[RFC PATCH 2/4] ftrace: Centralize task filter state updates hu.shengming
2026-08-30 11:12 ` [RFC PATCH 3/4] ftrace: Add exact task comm filtering hu.shengming
2026-08-30 11:12 ` [RFC PATCH 4/4] Documentation/ftrace: Document function comm filters hu.shengming
2026-08-30 15:27   ` Randy Dunlap
2026-08-31 10:52     ` hu.shengming
2026-08-31  1:20 ` [RFC PATCH 0/4] ftrace: Add task comm filtering for function tracing Masami Hiramatsu
2026-08-31 10:41   ` hu.shengming
2026-08-31 13:49 ` Steven Rostedt
2026-09-03  1:03   ` hu.shengming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox