From: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>
To: rostedt@goodmis.org
Cc: linux-trace-devel@vger.kernel.org
Subject: [PATCH 4/4] trace-cmd library man pages: Extend the examples of reading host-guest trace data
Date: Thu, 21 Jan 2021 12:36:05 +0200 [thread overview]
Message-ID: <20210121103605.224108-5-tz.stoyanov@gmail.com> (raw)
In-Reply-To: <20210121103605.224108-1-tz.stoyanov@gmail.com>
The trace-cmd library supports reading trace data from a host and
multiple guest machines as a single trace session, if they are recorded
at the same time. Added more relevant example in the man page, showing
that use case.
Signed-off-by: Tzvetomir Stoyanov (VMware) <tz.stoyanov@gmail.com>
---
.../libtracecmd/libtracecmd-peer.3.txt | 56 ++++++++++++-------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/Documentation/libtracecmd/libtracecmd-peer.3.txt b/Documentation/libtracecmd/libtracecmd-peer.3.txt
index 5cb0c4fa..6cf34f9b 100644
--- a/Documentation/libtracecmd/libtracecmd-peer.3.txt
+++ b/Documentation/libtracecmd/libtracecmd-peer.3.txt
@@ -74,36 +74,54 @@ EXAMPLE
--
#include <trace-cmd.h>
...
-struct tracecmd_input *host = tracecmd_open_head("trace.dat");
+struct tracecmd_input *host = tracecmd_open("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 */
+struct tracecmd_input *guest1 = tracecmd_open_head("trace-Guest1.dat");
+ if (!guest1) {
+ /* Failed to open guest1 trace file */
+ }
+struct tracecmd_input *guest2 = tracecmd_open_head("trace-Guest2.dat");
+ if (!guest2) {
+ /* Failed to open guest2 trace file */
}
-unsigned long long guest_id = tracecmd_get_traceid(guest);
-int *cpu_pid;
-char *name;
-int vcount;
+unsigned long long guest_id_1 = tracecmd_get_traceid(guest1);
+unsigned long long guest_id_2 = tracecmd_get_traceid(guest2);
+bool g1 = false, g2 = false;
+int *cpu_pid_1, *cpu_pid_2;
+int vcount_1, vcount_2;
+char *name_1, *name_2;
- 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_get_guest_cpumap(host, guest_id_1, &name_1, &vcount_1, &cpu_pid_1)) {
+ /* The Host and a guest1 with name_1 are part of the same trace session.
+ * Got guest1 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);
+ if (!tracecmd_pair_peer(guest1, host)) {
+ /* Successfully paired guest1 to the host handler */
+ tracecmd_init_data(guest1);
+ g1 = true;
+ }
+ }
+ if (!tracecmd_get_guest_cpumap(host, guest_id_2, &name_2, &vcount_2, &cpu_pid_2)) {
+ /* The Host and a guest2 with name_2 are part of the same trace session.
+ * Got guest2 VCPU to host PID mapping.
+ */
+ if (!tracecmd_pair_peer(guest2, host)) {
+ /* Successfully paired guest2 to the host handler */
+ tracecmd_init_data(guest2);
+ g2 = true;
}
}
-
...
- tracecmd_close(guest);
+ if (g1)
+ tracecmd_unpair_peer(guest1);
+ if (g2)
+ tracecmd_unpair_peer(guest2);
+ tracecmd_close(guest1);
+ tracecmd_close(guest2);
tracecmd_close(handle);
--
--
2.29.2
prev parent reply other threads:[~2021-01-21 10:37 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-21 10:36 [PATCH 0/4] trace-cmd libaray APIs and man pages Tzvetomir Stoyanov (VMware)
2021-01-21 10:36 ` [PATCH 1/4] trace-cmd library: Export 2 APIs for opening trace file Tzvetomir Stoyanov (VMware)
2021-01-21 10:36 ` [PATCH 2/4] trace-cmd: Remove tracecmd_unpair_peer() from internal header Tzvetomir Stoyanov (VMware)
2021-01-21 10:36 ` [PATCH 3/4] trace-cmd library man pages: Documented APIs for opening trace file Tzvetomir Stoyanov (VMware)
2021-01-21 10:36 ` Tzvetomir Stoyanov (VMware) [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210121103605.224108-5-tz.stoyanov@gmail.com \
--to=tz.stoyanov@gmail.com \
--cc=linux-trace-devel@vger.kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).