1*58e6ee5fSAndroid Build Coastguard Workerlibtracecmd(3) 2*58e6ee5fSAndroid Build Coastguard Worker============= 3*58e6ee5fSAndroid Build Coastguard Worker 4*58e6ee5fSAndroid Build Coastguard WorkerNAME 5*58e6ee5fSAndroid Build Coastguard Worker---- 6*58e6ee5fSAndroid Build Coastguard Workertracecmd_get_traceid, tracecmd_get_guest_cpumap - Manage trace session with multiple trace peers, 7*58e6ee5fSAndroid Build Coastguard Workerrecorded in multiple trace files. 8*58e6ee5fSAndroid Build Coastguard Worker 9*58e6ee5fSAndroid Build Coastguard WorkerSYNOPSIS 10*58e6ee5fSAndroid Build Coastguard Worker-------- 11*58e6ee5fSAndroid Build Coastguard Worker[verse] 12*58e6ee5fSAndroid Build Coastguard Worker-- 13*58e6ee5fSAndroid Build Coastguard Worker*#include <trace-cmd.h>* 14*58e6ee5fSAndroid Build Coastguard Worker 15*58e6ee5fSAndroid Build Coastguard Workerunsigned long long *tracecmd_get_traceid*(struct tracecmd_input pass:[*]_handle_); 16*58e6ee5fSAndroid Build Coastguard Workerint *tracecmd_get_guest_cpumap*(struct tracecmd_input pass:[*]_handle_, unsigned long long _trace_id_, const char pass:[*]pass:[*]_name_, int pass:[*]_vcpu_count_, const int pass:[*]pass:[*]_cpu_pid_); 17*58e6ee5fSAndroid Build Coastguard Worker-- 18*58e6ee5fSAndroid Build Coastguard Worker 19*58e6ee5fSAndroid Build Coastguard WorkerDESCRIPTION 20*58e6ee5fSAndroid Build Coastguard Worker----------- 21*58e6ee5fSAndroid Build Coastguard WorkerThis set of APIs can be used to manage a trace session with multiple trace 22*58e6ee5fSAndroid Build Coastguard Workerpeers, for example, tracing both a host and one or more guest virtual machines. 23*58e6ee5fSAndroid Build Coastguard WorkerThe trace data of each peer from the session is recorded in separate trace files. 24*58e6ee5fSAndroid Build Coastguard WorkerInformation about peers from the session is stored in the metadata of each 25*58e6ee5fSAndroid Build Coastguard Workertrace file. These APIs use that information to extract and synchronize 26*58e6ee5fSAndroid Build Coastguard Workerthe trace data. 27*58e6ee5fSAndroid Build Coastguard Worker 28*58e6ee5fSAndroid Build Coastguard WorkerThe _tracecmd_get_traceid()_ function returns the trace ID stored in 29*58e6ee5fSAndroid Build Coastguard Workerthe trace file metadata associated with _handle_. Each peer from a trace 30*58e6ee5fSAndroid Build Coastguard Workersession has an ID unique for that peer and that trace session only. 31*58e6ee5fSAndroid Build Coastguard WorkerThis ID is used to match multiple trace files recorded in a same trace 32*58e6ee5fSAndroid Build Coastguard Workersession. 33*58e6ee5fSAndroid Build Coastguard Worker 34*58e6ee5fSAndroid Build Coastguard WorkerThe _tracecmd_get_guest_cpumap()_ function gets the mapping of guest 35*58e6ee5fSAndroid Build Coastguard Workervirtual CPUs (VCPU) to the host process that represents those VCPUs and is 36*58e6ee5fSAndroid Build Coastguard Workerstored in the metadata of the trace file associated with _handle_. This 37*58e6ee5fSAndroid Build Coastguard Workerinformation is gathered during a host-guest trace session and is stored 38*58e6ee5fSAndroid Build Coastguard Workerin the host trace file. The _trace_id_ parameter is the trace ID of the guest 39*58e6ee5fSAndroid Build Coastguard Workerin this particular trace session. If a guest with that ID was part of that 40*58e6ee5fSAndroid Build Coastguard Workersession, its VCPU to host process mapping is in the host trace file and the 41*58e6ee5fSAndroid Build Coastguard Workerinformation is returned in _name_, _vcpu_count_ and _cpu_pid_ parameters. 42*58e6ee5fSAndroid Build Coastguard WorkerThe _name_ parameter contains the name of the guest, the _vcpu_count_ contains 43*58e6ee5fSAndroid Build Coastguard Workerthe count of VCPUs of that guest and the _cpu_pid_ array contains the VCPU to 44*58e6ee5fSAndroid Build Coastguard Workerhost process mapping. The array is of size _vcpu_count_ where the index is VCPU 45*58e6ee5fSAndroid Build Coastguard Workerand the value is the process ID (PID) of the host process, running that VCPU. 46*58e6ee5fSAndroid Build Coastguard WorkerThe _name_, _vcpu_count_ and _cpu_pid_ values must *not* be freed. 47*58e6ee5fSAndroid Build Coastguard Worker 48*58e6ee5fSAndroid Build Coastguard WorkerRETURN VALUE 49*58e6ee5fSAndroid Build Coastguard Worker------------ 50*58e6ee5fSAndroid Build Coastguard WorkerThe _tracecmd_get_traceid()_ function returns a 64 bit trace ID. 51*58e6ee5fSAndroid Build Coastguard Worker 52*58e6ee5fSAndroid Build Coastguard WorkerThe _tracecmd_get_guest_cpumap()_ function returns -1 in case of 53*58e6ee5fSAndroid Build Coastguard Workeran error or 0 otherwise. If 0 is returned, then the _name_, _vcpu_count_ 54*58e6ee5fSAndroid Build Coastguard Workerand _cpu_pid_ parameters contain the requested information. 55*58e6ee5fSAndroid Build Coastguard Worker 56*58e6ee5fSAndroid Build Coastguard WorkerEXAMPLE 57*58e6ee5fSAndroid Build Coastguard Worker------- 58*58e6ee5fSAndroid Build Coastguard Worker[source,c] 59*58e6ee5fSAndroid Build Coastguard Worker-- 60*58e6ee5fSAndroid Build Coastguard Worker#include <trace-cmd.h> 61*58e6ee5fSAndroid Build Coastguard Worker... 62*58e6ee5fSAndroid Build Coastguard Workerstruct tracecmd_input *host = tracecmd_open("trace.dat"); 63*58e6ee5fSAndroid Build Coastguard Worker if (!host) { 64*58e6ee5fSAndroid Build Coastguard Worker /* Failed to open host trace file */ 65*58e6ee5fSAndroid Build Coastguard Worker } 66*58e6ee5fSAndroid Build Coastguard Worker 67*58e6ee5fSAndroid Build Coastguard Workerstruct tracecmd_input *guest1 = tracecmd_open_head("trace-Guest1.dat"); 68*58e6ee5fSAndroid Build Coastguard Worker if (!guest1) { 69*58e6ee5fSAndroid Build Coastguard Worker /* Failed to open guest1 trace file */ 70*58e6ee5fSAndroid Build Coastguard Worker } 71*58e6ee5fSAndroid Build Coastguard Workerstruct tracecmd_input *guest2 = tracecmd_open_head("trace-Guest2.dat"); 72*58e6ee5fSAndroid Build Coastguard Worker if (!guest2) { 73*58e6ee5fSAndroid Build Coastguard Worker /* Failed to open guest2 trace file */ 74*58e6ee5fSAndroid Build Coastguard Worker } 75*58e6ee5fSAndroid Build Coastguard Worker 76*58e6ee5fSAndroid Build Coastguard Workerunsigned long long guest_id_1 = tracecmd_get_traceid(guest1); 77*58e6ee5fSAndroid Build Coastguard Workerunsigned long long guest_id_2 = tracecmd_get_traceid(guest2); 78*58e6ee5fSAndroid Build Coastguard Workerint *cpu_pid_1, *cpu_pid_2; 79*58e6ee5fSAndroid Build Coastguard Workerint vcount_1, vcount_2; 80*58e6ee5fSAndroid Build Coastguard Workerchar *name_1, *name_2; 81*58e6ee5fSAndroid Build Coastguard Worker 82*58e6ee5fSAndroid Build Coastguard Worker if (!tracecmd_get_guest_cpumap(host, guest_id_1, &name_1, &vcount_1, &cpu_pid_1)) { 83*58e6ee5fSAndroid Build Coastguard Worker /* The Host and a guest1 with name_1 are part of the same trace session. 84*58e6ee5fSAndroid Build Coastguard Worker * Got guest1 VCPU to host PID mapping. 85*58e6ee5fSAndroid Build Coastguard Worker */ 86*58e6ee5fSAndroid Build Coastguard Worker } 87*58e6ee5fSAndroid Build Coastguard Worker if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name_2, &vcount_2, &cpu_pid_2)) { 88*58e6ee5fSAndroid Build Coastguard Worker /* The Host and a guest2 with name_2 are part of the same trace session. 89*58e6ee5fSAndroid Build Coastguard Worker * Got guest2 VCPU to host PID mapping. 90*58e6ee5fSAndroid Build Coastguard Worker */ 91*58e6ee5fSAndroid Build Coastguard Worker } 92*58e6ee5fSAndroid Build Coastguard Worker... 93*58e6ee5fSAndroid Build Coastguard Worker tracecmd_close(guest1); 94*58e6ee5fSAndroid Build Coastguard Worker tracecmd_close(guest2); 95*58e6ee5fSAndroid Build Coastguard Worker tracecmd_close(handle); 96*58e6ee5fSAndroid Build Coastguard Worker 97*58e6ee5fSAndroid Build Coastguard Worker-- 98*58e6ee5fSAndroid Build Coastguard WorkerFILES 99*58e6ee5fSAndroid Build Coastguard Worker----- 100*58e6ee5fSAndroid Build Coastguard Worker[verse] 101*58e6ee5fSAndroid Build Coastguard Worker-- 102*58e6ee5fSAndroid Build Coastguard Worker*trace-cmd.h* 103*58e6ee5fSAndroid Build Coastguard Worker Header file to include in order to have access to the library APIs. 104*58e6ee5fSAndroid Build Coastguard Worker*-ltracecmd* 105*58e6ee5fSAndroid Build Coastguard Worker Linker switch to add when building a program that uses the library. 106*58e6ee5fSAndroid Build Coastguard Worker-- 107*58e6ee5fSAndroid Build Coastguard Worker 108*58e6ee5fSAndroid Build Coastguard WorkerSEE ALSO 109*58e6ee5fSAndroid Build Coastguard Worker-------- 110*58e6ee5fSAndroid Build Coastguard Worker_libtracefs(3)_, 111*58e6ee5fSAndroid Build Coastguard Worker_libtraceevent(3)_, 112*58e6ee5fSAndroid Build Coastguard Worker_trace-cmd(1)_ 113*58e6ee5fSAndroid Build Coastguard Worker_trace-cmd.dat(5)_ 114*58e6ee5fSAndroid Build Coastguard Worker 115*58e6ee5fSAndroid Build Coastguard WorkerAUTHOR 116*58e6ee5fSAndroid Build Coastguard Worker------ 117*58e6ee5fSAndroid Build Coastguard Worker[verse] 118*58e6ee5fSAndroid Build Coastguard Worker-- 119*58e6ee5fSAndroid Build Coastguard Worker*Steven Rostedt* <[email protected]> 120*58e6ee5fSAndroid Build Coastguard Worker*Tzvetomir Stoyanov* <[email protected]> 121*58e6ee5fSAndroid Build Coastguard Worker-- 122*58e6ee5fSAndroid Build Coastguard WorkerREPORTING BUGS 123*58e6ee5fSAndroid Build Coastguard Worker-------------- 124*58e6ee5fSAndroid Build Coastguard WorkerReport bugs to <[email protected]> 125*58e6ee5fSAndroid Build Coastguard Worker 126*58e6ee5fSAndroid Build Coastguard WorkerLICENSE 127*58e6ee5fSAndroid Build Coastguard Worker------- 128*58e6ee5fSAndroid Build Coastguard Workerlibtracecmd is Free Software licensed under the GNU LGPL 2.1 129*58e6ee5fSAndroid Build Coastguard Worker 130*58e6ee5fSAndroid Build Coastguard WorkerRESOURCES 131*58e6ee5fSAndroid Build Coastguard Worker--------- 132*58e6ee5fSAndroid Build Coastguard Workerhttps://git.kernel.org/pub/scm/utils/trace-cmd/trace-cmd.git/ 133*58e6ee5fSAndroid Build Coastguard Worker 134*58e6ee5fSAndroid Build Coastguard WorkerCOPYING 135*58e6ee5fSAndroid Build Coastguard Worker------- 136*58e6ee5fSAndroid Build Coastguard WorkerCopyright \(C) 2020 VMware, Inc. Free use of this software is granted under 137*58e6ee5fSAndroid Build Coastguard Workerthe terms of the GNU Public License (GPL). 138