Skip to content

RFC tracing: Lowering the footprint of TRACE_EVENTs

Steven Rostedt lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 RFC Latest10 patches 4 repliesIn review

Changes in v3 from the cover letter

o Ported to latest tip/tracing/core

o Fixed typo in change log that a comment in LWN noticed:
Wrote: 15999394 when it should have been 15888394. (Note: these numbers are from the original posting. I need to
redo them again before posting officially).

o Added Mathieu Desnoyers's check_trace patch that will check the callback to make sure it matches what DECLARE_TRACE() expects it.

o Added the check_trace to the ftrace and perf callback probes. Note, kprobes and syscalls do not use the register tracepoint so they are not affected.

o Moved the define of DECLARE_TRACE() and DECLARE_TRACE_NOARGS() out of the #ifdef CONFIG_TRACEPOINTS, since they were the same whether or not CONFIG_TRACEPOINTS was enabled. The internal __DECLARE_TRACE() changed.

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/10tracing: Create class struct for eventsinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +5 more+54 -460 replies
2/10tracepoints: Add check trace callback typeinclude/linux/tracepoint.h+6 -10 replies
3/10tracing: Let tracepoints have data passed to tracepoint callbacksinclude/linux/tracepoint.h include/trace/ftrace.h kernel/trace/blktrace.c +10 more+293 -2050 replies
4/10tracing: Remove per event trace registeringinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +4 more+167 -1450 replies
5/10tracing: Move fields from event to class structureinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +7 more+102 -460 replies
6/10tracing: Move raw_init from events to classinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +4 more+17 -180 replies
7/10tracing: Allow events to share their print functionsinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +9 more+186 -900 replies
8/10tracing: Move print functions into event classinclude/linux/ftrace_event.h include/linux/syscalls.h include/trace/ftrace.h +3 more+41 -520 replies
9/10tracing: Remove duplicate id information in event structureinclude/linux/ftrace_event.h include/trace/ftrace.h kernel/trace/trace_event_perf.c +5 more+34 -320 replies
10/10tracing: Combine event filter_active and enable into single flags fieldinclude/linux/ftrace_event.h kernel/trace/trace.h kernel/trace/trace_events.c +2 more+33 -164 replies

Reviews trailers per patch

6 of 10 patches have a Reviewed-by or Acked-by.

PatchFrederic WeisbeckerMathieu Desnoyers
1/10A-b
2/10
3/10
4/10
5/10A-b
6/10A-b
7/10A-b
8/10A-b
9/10
10/10A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/10 -v3][RFC] tracing: Lowering the footprint of TRACE_EVENTs

[Version 3]

OK, this should be my final RFC release. If there are no complaints about this one, I'll post it as an official git pull.

This also affecs kprobes and perf.

At the Linux Collaboration Summit, I talked with Mathieu and others about lowering the footprint of trace events. I spent all of last week trying to get the size as small as I could.

Currently, each TRACE_EVENT() macro adds 1 - 5K per tracepoint. I got various results by adding a TRACE_EVENT() with the compiler, depending on config options that did not seem related. The new tracepoint I added would add between 1 and 5K, but I did not investigate enough to see what the true size was.

What was consistent, was the DEFINE_EVENT(). Currently, it adds a little over 700 bytes per DEFINE_EVENT().

This patch series does not seem to affect TRACE_EVENT() much (had the same various sizes), but consistently brings DEFINE_EVENT()s down from 700 bytes to 250 bytes per DEFINE_EVENT(). Since syscalls use one "class" and are equivalent to DEFINE_EVENT() this can be a significant savings.

With events and syscalls (82 events and 616 syscalls), before this patch series, the size of vmlinux was: 16161794, and afterward: 16058182.

That is 103,612 bytes in savings! (over 100K)

Without tracing syscalls (82 events), it brought the size of vmlinux down from 1591046 to 15888394.

22,071 bytes in savings.

This is just an RFC (for now), to get peoples opinions on the changes. It does a bit of rewriting of the CPP macros, just to warning you ;-)

Changes in v3:

o Ported to latest tip/tracing/core

o Fixed typo in change log that a comment in LWN noticed:
Wrote: 15999394 when it should have been 15888394. (Note: these numbers are from the original posting. I need to
redo them again before posting officially).

o Added Mathieu Desnoyers's check_trace patch that will check the callback to make sure it matches what DECLARE_TRACE() expects it.

o Added the check_trace to the ftrace and perf callback probes. Note, kprobes and syscalls do not use the register tracepoint so they are not affected.

o Moved the define of DECLARE_TRACE() and DECLARE_TRACE_NOARGS() out of the #ifdef CONFIG_TRACEPOINTS, since they were the same whether or not CONFIG_TRACEPOINTS was enabled. The internal __DECLARE_TRACE() changed.

Changes in v2:

o Ported to latest tip/tracing/core

o Removed DECLARE_TRACE_DATA() and made DECLARE_TRACE() have the ability to pass a data parameter. This makes DECLARE_TRACE() not work with no args. A new DECLARE_TRACE_NOARGS() has been created that also allows data to be passed, but does is for tracepoint(void).

o Made the callbacks be "proto, void *data" and typecast the data within the function.

-- Steve

The code can be found at:

git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-2.6-trace.git
tip/tracing/rfc-1

Mathieu Desnoyers (1):
tracepoints: Add check trace callback type

Steven Rostedt (9):
tracing: Create class struct for events
tracing: Let tracepoints have data passed to tracepoint callbacks
tracing: Remove per event trace registering
tracing: Move fields from event to class structure
tracing: Move raw_init from events to class
tracing: Allow events to share their print functions
tracing: Move print functions into event class
tracing: Remove duplicate id information in event structure
tracing: Combine event filter_active and enable into single flags field

----

 include/linux/ftrace_event.h                   |   73 ++++++--
 include/linux/syscalls.h                       |   57 ++----
 include/linux/tracepoint.h                     |   98 ++++++++---
 include/trace/ftrace.h                         |  233 +++++++++---------------
 include/trace/syscall.h                        |   10 +-
 kernel/trace/blktrace.c                        |  138 ++++++++------
 kernel/trace/ftrace.c                          |    7 +-
 kernel/trace/kmemtrace.c                       |   70 +++++---
 kernel/trace/trace.c                           |    9 +-
 kernel/trace/trace.h                           |    5 +-
 kernel/trace/trace_event_perf.c                |   17 ++-
 kernel/trace/trace_events.c                    |  131 +++++++++-----
 kernel/trace/trace_events_filter.c             |   28 ++--
 kernel/trace/trace_export.c                    |   16 +-
 kernel/trace/trace_functions_graph.c           |   13 +-
 kernel/trace/trace_kprobe.c                    |  104 +++++++----
 kernel/trace/trace_output.c                    |  137 ++++++++++-----
 kernel/trace/trace_output.h                    |    2 +-
 kernel/trace/trace_sched_switch.c              |   23 ++-
 kernel/trace/trace_sched_wakeup.c              |   27 ++--
 kernel/trace/trace_syscalls.c                  |  137 ++++++++++++---
 kernel/trace/trace_workqueue.c                 |   26 ++-
 kernel/tracepoint.c                            |   91 +++++----
 samples/tracepoints/tp-samples-trace.h         |    4 +-
 samples/tracepoints/tracepoint-probe-sample.c  |   13 +-
 samples/tracepoints/tracepoint-probe-sample2.c |    7 +-
 26 files changed, 879 insertions(+), 597 deletions(-)