mbox series

[0/4,WiP] trace-cmd: Add "perf" sub command

Message ID 20200807120655.797084-1-tz.stoyanov@gmail.com (mailing list archive)
Headers show
Series trace-cmd: Add "perf" sub command | expand

Message

Tzvetomir Stoyanov (VMware) Aug. 7, 2020, 12:06 p.m. UTC
A new "trace-cmd perf" sub command is implemented, to collect performance
information about a user space program, using perf. The command has one
argumemnt, mandatory, using to specify a PID of running userspace process:
 trace-cmd perf --pid <PID>
This is a work in progress, not completed yet.

What is implemented:
 - Initial infrastructure for configuring perf, using its kernel interface,
 and running per CPU threads for reading collected perf data. Perf is used 
 to collect periodically CALLCHAINs (values of IP register) of the requested
 PID.
 - trace-cmd internal APIs, wrapper around libbfd, for parsing an ELF header.
 - Resolving collected IP values to function names, using the binary file of
   the running application and all libraries that it uses.
 - New trace.dat file option for storing address to function name mapping
   and a new API for address to name resolving using stored information.

What is not yet implemented:
 - There are problems reading the perf mmap pages with collected data,
   currently only the first few records from each CPU page are read correctly.
 - Assemble the trace.dat file with all mandatory headers. Think about a new
   type of trace data in the file and its format. This should be designed
   flexible, to be able to store various perf data, not only CALLCHAINs.
 - Add support in "trace-dat report" for reporting the new data.
 - Add APIs in libtracecmd for reading the new data.
 - Enable collecting of kernel functions in the CALLCHAIN and implement
   resolving of kernel address to a kernel function name.
 - Formatting and beautifying the code.
 - A lot of testing and bug fixing.

Tzvetomir Stoyanov (VMware) (4):
  trace-cmd: Internal refactoring of pid address map logic
  trace-cmd: New internal APIs for reading ELF header
  trace-cmd: Add a new option in trace.dat file for the address to
    function name mapping
  trace-cmd: Add new subcomand "trace-cmd perf"

 Makefile                       |  10 +
 include/trace-cmd/trace-cmd.h  |  13 +
 lib/trace-cmd/trace-input.c    | 144 ++++++
 tracecmd/Makefile              |   2 +
 tracecmd/include/trace-local.h |  33 +-
 tracecmd/trace-cmd.c           |   1 +
 tracecmd/trace-dump.c          |   3 +
 tracecmd/trace-obj-debug.c     | 770 +++++++++++++++++++++++++++++++++
 tracecmd/trace-perf.c          | 540 +++++++++++++++++++++++
 tracecmd/trace-record.c        | 107 +----
 10 files changed, 1510 insertions(+), 113 deletions(-)
 create mode 100644 tracecmd/trace-obj-debug.c
 create mode 100644 tracecmd/trace-perf.c