Re: [RFC] Open multiple trace files and, if possible, pair them

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

 



Hi Stefano,

On Fri, Mar 5, 2021 at 8:28 AM Stefano De Venuto
<stefano.devenuto99@xxxxxxxxx> wrote:
>
> The goal of this patch is to teach to trace-cmd how to open multiple
> files and, if they are generated by an host and some guests, pair and
> synchronize them.
>
> We do that by checking, for every input file, whether or not
> it has a corresponding peer, and if that's the case pairs them.
>
> We know that the code must be changed following the new API, but we
> would like to have an opinion on the work done so far.

Thanks for sending this patch!
This was exactly the missing functionality
in order to display host-guest trace files using the not-so-old trace-cmd
logic. I have only a few minor coding style comments and may be some
optimizations, but the patch looks good to me in general. If we haven't
decided to change the default behaviour of applying these TS corrections,
your fixes would be merged upstream.

>
> Signed-off-by: Stefano De Venuto <stefano.devenuto99@xxxxxxxxx>
> ---
>  tracecmd/trace-read.c | 35 +++++++++++++++++++++++++++++++++++
>  1 file changed, 35 insertions(+)
>
> diff --git a/tracecmd/trace-read.c b/tracecmd/trace-read.c
> index ce07b6b..734c2e7 100644
> --- a/tracecmd/trace-read.c
> +++ b/tracecmd/trace-read.c
> @@ -1191,6 +1191,39 @@ enum output_type {
>         OUTPUT_VERSION_ONLY,
>  };
>
> +static void pair_host_guest(struct list_head *handle_list,
> +                               struct tracecmd_input *peer_handle)
> +{
> +       unsigned long long current_trace_id;
> +       unsigned long long peer_trace_id;
> +       struct handle_list *handles;
> +
> +       peer_trace_id = tracecmd_get_traceid(peer_handle);
> +
> +       list_for_each_entry(handles, handle_list, list) {
> +
> +               current_trace_id = tracecmd_get_traceid(handles->handle);
> +
> +               /* If the current handle represents a Host */
> +               if (tracecmd_get_guest_cpumap(handles->handle, peer_trace_id,
> +                                               NULL, NULL, NULL) != -1) {
> +
> +                       current_trace_id = tracecmd_get_traceid(handles->handle);
> +                       if (tracecmd_get_tsync_peer(peer_handle) == current_trace_id)
> +                               tracecmd_pair_peer(peer_handle, handles->handle);
> +
> +               /* If the current handle represents a Guest */
> +               } else if (tracecmd_get_tsync_peer(handles->handle) == peer_trace_id) {
> +
> +                       current_trace_id = tracecmd_get_traceid(handles->handle);
> +                       if (tracecmd_get_guest_cpumap(peer_handle, current_trace_id,
> +                                                       NULL, NULL, NULL) != -1)
> +                               tracecmd_pair_peer(handles->handle, peer_handle);
> +
> +               }
> +       }
> +}
> +
>  static void read_data_info(struct list_head *handle_list, enum output_type otype,
>                            int global)
>  {
> @@ -1837,6 +1870,8 @@ void trace_report (int argc, char **argv)
>                                 return;
>                 }
>
> +               pair_host_guest(&handle_list, handle);
> +
>                 if (show_funcs) {
>                         tep_print_funcs(pevent);
>                         return;
> --
> 2.30.0
>


-- 
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