Open multiple trace files and, if possible, pair them
RFC 1/1 Open multiple trace files and, if possible, pair them
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.
--- tracecmd/trace-read.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)
tracecmd/trace-read.c +35 -0
@@ -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 ;
Signature · 1 line
2.30.0
Hi Stefano!
Great to see your patch here on the list! :-)
Quoted 7 lines · Stefano De Venuto
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.
Exactly. So, for the trace-devel community: our (Stefano's and mine :-D) end goal is to do some analysis & manipulation on a combined host+guest(s) trace file. Of course, in order to do that, we need a nice and easy way to get such a trace file!
Implementing the support for that in trace-cmd seemed the most reasonable first step, so we reached out and decided to work on
https://bugzilla.kernel.org/show_bug.cgi?id=211657 , which is what this patch does.
Now ...
Quoted 3 lines
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.
... the API is changing, so we'll have to adapt it.
Still, the patch includes, e.g., the logic for opening multiple trace files and figuring out whether they are guest or host, etc.
And maybe these bits are still valid and you're able/willing to give us some feedback on whether they make sense? :-)
Quoted 5 lines
Signed-off-by Stefano De Venuto <[email protected]>---
tracecmd/trace-read.c | 35 +++++++++++++++++++++++++++++++++++1 file changed, 35 insertions(+)
For Stefano: about the patch itself, I think the only thing I'm going to say is that some of the lines look a bit long.
I do not see a CODING_STYLE file in the repo, but just looking around, I got the impression that we should stay within 76-80 characters all the times that it is possible.
And that's it, and I'm happy to let the experts speak, as I'm only trying to learn trace-cmd internals myself. ;-D
Thanks and Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
Quoted 6 lines · On Fri, 05 Mar 2021 10:18:07 +0100 [email protected] wrote:
For Stefano: about the patch itself, I think the only thing I'm going to say is that some of the lines look a bit long.
I do not see a
CODING_STYLEfile in the repo, but just looking around, I got the impression that we should stay within 76-80 characters all the times that it is possible.
Honestly, I'm not a fan of the 80 character limit. I don't want lines that are 200 characters long either. My windows are normally between 90 and 100 characters wide, so keeping it under 100 is fine with me. Especially if it keeps the code looking better.
For example:
+ 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);
Should be either:
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);
or:
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);
}Two changes above:
If you break a if conditional up, that categorizes it as a "complex" statement and brackets should be used. (This is also for Linux kernel coding style).
The second is, if you break up a function call parameters, the parameters starting on the next line should line up with the starting parenthesis. Note, this is not always the case. If the broken line is still long, it is OK to have the line start before the parenthesis to keep it symmetrical:
current_trace_id = tracecmd_get_traceid(handles->handle);
if (tracecmd_get_guest_cpumap(peer_handle, current_trace_id,
some_string, another_string, bigger_string_as_well) != -1) {
tracecmd_pair_peer(handles->handle, peer_handle);
}But that too should be avoided if possible.
Thanks!
-- Steve
Hi Stefano,
Quoted 10 lines · Stefano De Venuto
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.
Quoted 62 lines
Signed-off-by Stefano De Venuto <[email protected]>--- tracecmd/trace-read.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+)tracecmd/trace-read.c +35
-1@@ -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
Signature · 2 lines
Tzvetomir (Ceco) Stoyanov VMware Open Source Technology Center
Hey everyone,
Sorry for the late reply...
Quoted 5 lines · Tzvetomir Stoyanov
Hi Stefano,
Quoted 1 line · Stefano De Venuto
Quoted 9 lines
Quoted 6 lines
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.Thanks for sending this patch!
Thanks to you for the quick feedback!
Quoted 5 lines
If we haven't
decided to change the default behaviour of applying these TS corrections,
your fixes would be merged upstream.
Yeah, great timing on our side! :-D
So, what would be the way forward here. I'm guessing re-doing the patch on top of the new API?
If yes, Stefano, are you up for having a look at how that could be done?
Thanks again and Regards,
Dario
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)
Quoted 3 lines · On Thu, 11 Mar 2021 18:37:03 +0100 Dario Faggioli <[email protected]> wrote:
So, what would be the way forward here. I'm guessing re-doing the patch on top of the new API?
With the new API it may not be necessary.
As we are making it where the guest files will show the same output regardless of being paired or not by default. That is, we are going to store the synchronization information in each trace.dat file (for the host and all the guests), and the trace.dat files will display the same time stamp regardless of if it is being displayed with other trace.dat files or stand alone.
As trace-cmd already merges by time stamp of multiple trace files, I'm not sure there would be anything more to do once we implement the new API.
-- Steve
Quoted 2 lines · On Thu, 11 Mar 2021 12:50:40 -0500 Steven Rostedt <[email protected]> wrote:
As trace-cmd already merges by time stamp of multiple trace files, I'm not sure there would be anything more to do once we implement the new API.
That said, we are hoping to have the new API out shortly, and it would be fantastic if you could start testing it!
Thanks,
-- Steve
Quoted 9 lines · Steven Rostedt
Quoted 4 lines · On Thu, 11 Mar 2021 18:37:03 +0100 Dario Faggioli <[email protected]> wrote:
So, what would be the way forward here. I'm guessing re-doing the patch
on top of the new API?With the new API it may not be necessary.
Right.
Quoted 11 lines
As we are making it where the guest files will show the same output regardless of being paired or not by default. That is, we are going to
store the synchronization information in each trace.dat file (for the host
and all the guests), and the trace.dat files will display the same time
stamp regardless of if it is being displayed with other trace.dat files or
stand alone.
Yep, saw it.
In fact, my mistake was to think that opening multiple trace files would still need some work. But, as a matter of fact, that also works already, right?
In which case, we will "just" apply the patches with the new API and continue our work on top of them.
And sorry for the noise. :-)
Regards
Signature · 6 lines
Dario Faggioli, Ph.D http://about.me/dario.faggioli Virtualization Software Engineer SUSE Labs, SUSE https://www.suse.com/ ------------------------------------------------------------------- <<This happens because _I_ choose it to happen!>> (Raistlin Majere)