Bug 211657

Summary: Feature Request, trace-cmd: Extend trace-cmd report to open host and multiple guests trace files
Product: Tools Reporter: Tzvetomir Stoyanov (tstoyanov)
Component: Trace-cmd/KernelsharkAssignee: Default virtual assignee for Trace-cmd and kernelshark (tools_tracecmd_kernelshark)
Status: RESOLVED OBSOLETE    
Severity: normal    
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 5.10 Subsystem:
Regression: No Bisected commit-id:

Description Tzvetomir Stoyanov 2021-02-09 16:51:21 UTC
When tracing host and guest machines using trace-cmd agent, a couple of trace.dat files are generated - one for the host and one for each guest being traced. Currently there is no way to open those files together, as part of a same tracing session, using trace-cmd.
"trace-cmd report" should be extended to open multiple files and to check if they are part of the same host-guest tracing session. If this is true, metadata from the guest tracing files should be used to align guest event timestamps to the host time, merge and show tracing data from all files together. There are trace-cmd APIs for that, used by upcoming Kernel Shark 2.
The logic should be:
 1. Get the host trace-id, stored in the host trace file.
 2. Get the list of traced guests, from the host trace file. 
 3. Get the guest trace-id, stored in the guest trace file and check if it is in the list of traced guests (from point 2)
 4. Get the peer's trace-id from guest trace file and check if it matches the host trace-id (from point 1)
 5 If there is a match, use TimeShift information from guest trace file to adjust timestamps of that guest, before showing them.

These trace-cmd APIs can be used:
  tracecmd_get_traceid()
  tracecmd_get_guest_cpumap()
  tracecmd_pair_peer()
  tracecmd_unpair_peer()

already used by Kernel Shark 2 beta.
Comment 1 Tzvetomir Stoyanov 2021-03-05 03:10:42 UTC
As the logic for opening trace files with host and guest trace data is simplified,
the timestamps are recalculated by default, this issue is not relevant any more.
The pairing APIs tracecmd_pair_peer() and tracecmd_unpair_peer() are removed.

https://patchwork.kernel.org/project/linux-trace-devel/list/?series=442035