|
|
9ae3a8 |
From af89b472e5fb4743a41cd7304ac831e777eadaa4 Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 7 Oct 2014 14:06:51 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 33/43] trace: add pid field to simpletrace record
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Message-id: <1412690820-31016-3-git-send-email-stefanha@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 61607
|
|
|
9ae3a8 |
O-Subject: [RHEL7.1 qemu-kvm PATCH 02/11] trace: add pid field to simpletrace record
|
|
|
9ae3a8 |
Bugzilla: 1088112
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
It is useful to know the QEMU process ID when working with traces from
|
|
|
9ae3a8 |
multiple VMs. Although the trace filename may contain the pid, tools
|
|
|
9ae3a8 |
that aggregate traces or even trace globally need somewhere to record
|
|
|
9ae3a8 |
the pid.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
There is a reserved field in the trace event header struct that we can
|
|
|
9ae3a8 |
use.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
It is not necessary to bump the simpletrace file format version number
|
|
|
9ae3a8 |
because it has already been incremented for the QEMU 2.1 release cycle
|
|
|
9ae3a8 |
in commit "trace: [simple] Bump up log version number".
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit 26896cbf353e3017f76da8193074839b6e875250)
|
|
|
9ae3a8 |
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Conflicts:
|
|
|
9ae3a8 |
trace/simple.c
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Downstream still has a g_thread_init() call in trace/simple.c so there
|
|
|
9ae3a8 |
is a context conflict. Easy to resolve.
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
trace/simple.c | 8 ++++++--
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/trace/simple.c b/trace/simple.c
|
|
|
9ae3a8 |
index 64e196a..479b7d2 100644
|
|
|
9ae3a8 |
--- a/trace/simple.c
|
|
|
9ae3a8 |
+++ b/trace/simple.c
|
|
|
9ae3a8 |
@@ -64,6 +64,7 @@ uint8_t trace_buf[TRACE_BUF_LEN];
|
|
|
9ae3a8 |
static volatile gint trace_idx;
|
|
|
9ae3a8 |
static unsigned int writeout_idx;
|
|
|
9ae3a8 |
static volatile gint dropped_events;
|
|
|
9ae3a8 |
+static uint32_t trace_pid;
|
|
|
9ae3a8 |
static FILE *trace_fp;
|
|
|
9ae3a8 |
static char *trace_file_name;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -72,7 +73,7 @@ typedef struct {
|
|
|
9ae3a8 |
uint64_t event; /* TraceEventID */
|
|
|
9ae3a8 |
uint64_t timestamp_ns;
|
|
|
9ae3a8 |
uint32_t length; /* in bytes */
|
|
|
9ae3a8 |
- uint32_t reserved; /* unused */
|
|
|
9ae3a8 |
+ uint32_t pid;
|
|
|
9ae3a8 |
uint64_t arguments[];
|
|
|
9ae3a8 |
} TraceRecord;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -180,7 +181,7 @@ static gpointer writeout_thread(gpointer opaque)
|
|
|
9ae3a8 |
dropped.rec.event = DROPPED_EVENT_ID,
|
|
|
9ae3a8 |
dropped.rec.timestamp_ns = get_clock();
|
|
|
9ae3a8 |
dropped.rec.length = sizeof(TraceRecord) + sizeof(uint64_t),
|
|
|
9ae3a8 |
- dropped.rec.reserved = 0;
|
|
|
9ae3a8 |
+ dropped.rec.pid = trace_pid;
|
|
|
9ae3a8 |
do {
|
|
|
9ae3a8 |
dropped_count = g_atomic_int_get(&dropped_events);
|
|
|
9ae3a8 |
} while (!g_atomic_int_compare_and_exchange(&dropped_events,
|
|
|
9ae3a8 |
@@ -239,6 +240,7 @@ int trace_record_start(TraceBufferRecord *rec, TraceEventID event, size_t datasi
|
|
|
9ae3a8 |
rec_off = write_to_buffer(rec_off, &event_u64, sizeof(event_u64));
|
|
|
9ae3a8 |
rec_off = write_to_buffer(rec_off, ×tamp_ns, sizeof(timestamp_ns));
|
|
|
9ae3a8 |
rec_off = write_to_buffer(rec_off, &rec_len, sizeof(rec_len));
|
|
|
9ae3a8 |
+ rec_off = write_to_buffer(rec_off, &trace_pid, sizeof(trace_pid));
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
rec->tbuf_idx = idx;
|
|
|
9ae3a8 |
rec->rec_off = (idx + sizeof(TraceRecord)) % TRACE_BUF_LEN;
|
|
|
9ae3a8 |
@@ -413,6 +415,8 @@ bool trace_backend_init(const char *events, const char *file)
|
|
|
9ae3a8 |
#endif
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+ trace_pid = getpid();
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
#if !GLIB_CHECK_VERSION(2, 31, 0)
|
|
|
9ae3a8 |
trace_available_cond = g_cond_new();
|
|
|
9ae3a8 |
trace_empty_cond = g_cond_new();
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|