Re: [PATCH 5/6] trace-cmd library man pages: Manage trace session with multiple trace peers.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jan 14, 2021 at 12:13 AM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
>
>
> I'm assuming that you can pair multiple guests with a single host?

Yes, this use case is tested using KernelShark. I'll extend the
example in the man page.

>
> That is, can we have:
>
>
>         bool g1 = false, g2 = false;
>
>         host = tracecmd_open_head("trace.dat");
>         tracecmd_init_data(host);
>         guest1 = tracecmd_open_head("trace-Guest-1.dat");
>         guest2 = tracecmd_open_head("trace-Guest-2.dat");
>
>         guest_id_1 = tracecmd_get_traceid(guest1);
>         guest_id_2 = tracecmd_get_traceid(guest1);
>
>         if (!tracecmd_get_guest_cpumap(host, guest_id_1, &name1, &vcount1, &cpu_pids1)
>                 g1 = !tracecmd_init_data(guest1);
>
>         if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name2, &vcount2, &cpu_pids2)
>                 g2 = !tracecmd_init_data(guest2);
>
>         if (g1) {
>                 int i;
>                 for (i = 0; i < vcount1; i++) {
>                         printf("Host task id %d maps to guest %s cpu %d\n",
>                                 cpu_pids1[i], name1, i);
>                 }
>                 tracecmd_unpair_peer(guest1);
>         }
>
>         if (g2) {
>                 int i;
>                 for (i = 0; i < vcount2; i++) {
>                         printf("Host task id %d maps to guest %s cpu %d\n",
>                                 cpu_pids2[i], name2, i);
>                 }
>                 tracecmd_unpair_peer(guest2);
>         }
>
> And use something like the above for the example?
>
> -- Steve
>
>
> On Wed, 23 Dec 2020 06:34:28 +0200
> "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@xxxxxxxxx> wrote:
>
> > +EXAMPLE
> > +-------
> > +[source,c]
> > +--
> > +#include <trace-cmd.h>
> > +...
> > +struct tracecmd_input *host = tracecmd_open_head("trace.dat");
> > +     if (!host) {
> > +             /* Failed to open host trace file */
> > +     }
> > +     tracecmd_init_data(host);
> > +
> > +struct tracecmd_input *guest = tracecmd_open_head("trace-Guest.dat");
> > +     if (!guest) {
> > +             /* Failed to open guest trace file */
> > +     }
> > +
> > +unsigned long long guest_id = tracecmd_get_traceid(guest);
> > +int *cpu_pid;
> > +char *name;
> > +int vcount;
> > +
> > +     if (!tracecmd_get_guest_cpumap(host, guest_id, &name, &vcount, &cpu_pid)) {
> > +             /* The Host and a guest with name was part of the same trace session.
> > +              * Got guest VCPU to host PID mapping.
> > +              */
> > +             if (!tracecmd_pair_peer(guest, host)) {
> > +                     /* Successfully paired host to the guest handler */
> > +                     tracecmd_init_data(guest);
> > +                     ...
> > +                     tracecmd_unpair_peer(guest);
> > +             }
> > +     }
> > +
> > +...
> > +     tracecmd_close(guest);
> > +     tracecmd_close(hadle);
> > +
> > +--



-- 
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center



[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux