* [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing
@ 2010-06-24 11:19 Prerna Saxena
2010-06-24 11:28 ` [Qemu-devel] [RFC v4][PATCH 1/3] Change type declarations Prerna Saxena
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-06-24 11:19 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Stefan Hajnoczi, kvm, Jan Kiszka,
Luiz Capitulino, Maneesh Soni, Ananth Narayan
This set of patches enables trace visualization & control
via the QEMU monitor. It is based on trace infrastructure posted
upstream :
( http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg02407.html )
This patchset adds monitor commands :
- info trace : to view current contents of the trace buffer
- info tracepoints : to view all available tracepoints and their state.
- tracepoint NAME on|off : to enable/disable the logging of dataThis is v3 of a set of patches to enable trace visualization & control
via the QEMU monitor.
Changelog from v3:
1. As suggested, it replaces a hash-based search of tracepoints
with a linear search.
2. Static initialization of trace event array.
3. Cleanups.
Changelog from v2:
1. Clean-ups, particularly relating to export of tdb_hash().
Changelog from v1:
1. Command 'info trace' is used to view current contents of buffer, in
place of 'trace'.
2. Cleanups
Todos :
1. Integration with QMP
2. More tracepoints need to be added for instrumenting other qemu components
such as virtio drivers, etc.
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Qemu-devel] [RFC v4][PATCH 1/3] Change type declarations
2010-06-24 11:19 [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Prerna Saxena
@ 2010-06-24 11:28 ` Prerna Saxena
2010-06-24 11:31 ` [Qemu-devel] [RFC v4][PATCH 2/3] Monitor command 'info trace' Prerna Saxena
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-06-24 11:28 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Stefan Hajnoczi, kvm, Jan Kiszka,
Luiz Capitulino, Soni, Ananth Narayan, Maneesh
Change type 'TraceEvent' to 'TraceEventID'
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
simpletrace.c | 12 ++++++------
tracetool | 12 ++++++------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/simpletrace.c b/simpletrace.c
index 2fec4d3..b488380 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -19,7 +19,7 @@ static TraceRecord trace_buf[TRACE_BUF_LEN];
static unsigned int trace_idx;
static FILE *trace_fp;
-static void trace(TraceEvent event, unsigned long x1,
+static void trace(TraceEventID event, unsigned long x1,
unsigned long x2, unsigned long x3,
unsigned long x4, unsigned long x5) {
TraceRecord *rec = &trace_buf[trace_idx];
@@ -43,22 +43,22 @@ static void trace(TraceEvent event, unsigned long x1,
}
}
-void trace1(TraceEvent event, unsigned long x1) {
+void trace1(TraceEventID event, unsigned long x1) {
trace(event, x1, 0, 0, 0, 0);
}
-void trace2(TraceEvent event, unsigned long x1, unsigned long x2) {
+void trace2(TraceEventID event, unsigned long x1, unsigned long x2) {
trace(event, x1, x2, 0, 0, 0);
}
-void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3) {
+void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3) {
trace(event, x1, x2, x3, 0, 0);
}
-void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4) {
+void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4) {
trace(event, x1, x2, x3, x4, 0);
}
-void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) {
+void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) {
trace(event, x1, x2, x3, x4, x5);
}
diff --git a/tracetool b/tracetool
index 9ea9c08..0dc7f1b 100755
--- a/tracetool
+++ b/tracetool
@@ -123,13 +123,13 @@ linetoc_end_nop()
linetoh_begin_simple()
{
cat <<EOF
-typedef unsigned int TraceEvent;
+typedef unsigned int TraceEventID;
-void trace1(TraceEvent event, unsigned long x1);
-void trace2(TraceEvent event, unsigned long x1, unsigned long x2);
-void trace3(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3);
-void trace4(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4);
-void trace5(TraceEvent event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5);
+void trace1(TraceEventID event, unsigned long x1);
+void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
+void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
+void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4);
+void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5);
EOF
simple_event_num=0
--
1.6.2.5
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [RFC v4][PATCH 2/3] Monitor command 'info trace'
2010-06-24 11:19 [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Prerna Saxena
2010-06-24 11:28 ` [Qemu-devel] [RFC v4][PATCH 1/3] Change type declarations Prerna Saxena
@ 2010-06-24 11:31 ` Prerna Saxena
2010-06-24 11:34 ` [Qemu-devel] [RFC v4][PATCH 3/3] Support for dynamically enabling/disabling trace events Prerna Saxena
2010-06-24 15:13 ` [Qemu-devel] Re: [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-06-24 11:31 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Stefan Hajnoczi, kvm, Jan Kiszka,
Luiz Capitulino, Soni, Ananth Narayan, Maneesh
Monitor command 'info trace' to display contents of trace buffer
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
configure | 3 +++
monitor.c | 12 ++++++++++++
qemu-monitor.hx | 4 ++++
simpletrace.c | 12 ++++++++++++
tracetool | 1 +
5 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/configure b/configure
index 675d0fc..56af8dd 100755
--- a/configure
+++ b/configure
@@ -2302,6 +2302,9 @@ bsd)
esac
echo "TRACE_BACKEND=$trace_backend" >> $config_host_mak
+if test "$trace_backend" = "simple"; then
+ echo "CONFIG_SIMPLE_TRACE=y" >> $config_host_mak
+fi
if test "$trace_backend" = "ust"; then
LIBS="-lust $LIBS"
fi
diff --git a/monitor.c b/monitor.c
index ad50f12..8b60830 100644
--- a/monitor.c
+++ b/monitor.c
@@ -55,6 +55,9 @@
#include "json-streamer.h"
#include "json-parser.h"
#include "osdep.h"
+#ifdef CONFIG_SIMPLE_TRACE
+#include "trace.h"
+#endif
//#define DEBUG
//#define DEBUG_COMPLETION
@@ -2780,6 +2783,15 @@ static const mon_cmd_t info_cmds[] = {
.help = "show roms",
.mhandler.info = do_info_roms,
},
+#if defined(CONFIG_SIMPLE_TRACE)
+ {
+ .name = "trace",
+ .args_type = "",
+ .params = "",
+ .help = "show current contents of trace buffer",
+ .mhandler.info = do_info_trace,
+ },
+#endif
{
.name = NULL,
},
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index b6e3467..766c30f 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -114,6 +114,10 @@ show migration status
show balloon information
@item info qtree
show device tree
+#ifdef CONFIG_SIMPLE_TRACE
+@item info trace
+show contents of trace buffer
+#endif
@end table
ETEXI
diff --git a/simpletrace.c b/simpletrace.c
index b488380..5734d15 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -1,5 +1,6 @@
#include <stdlib.h>
#include <stdio.h>
+#include "monitor.h"
#include "trace.h"
typedef struct {
@@ -62,3 +63,14 @@ void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned lon
void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5) {
trace(event, x1, x2, x3, x4, x5);
}
+
+void do_info_trace(Monitor *mon)
+{
+ unsigned int i;
+
+ for (i = 0; i < trace_idx ; i++) {
+ monitor_printf(mon, "Event %lu : %lx %lx %lx %lx %lx\n",
+ trace_buf[i].event, trace_buf[i].x1, trace_buf[i].x2,
+ trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);
+ }
+}
diff --git a/tracetool b/tracetool
index 0dc7f1b..6f8f8a9 100755
--- a/tracetool
+++ b/tracetool
@@ -130,6 +130,7 @@ void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4);
void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5);
+void do_info_trace(Monitor *mon);
EOF
simple_event_num=0
--
1.6.2.5
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] [RFC v4][PATCH 3/3] Support for dynamically enabling/disabling trace events.
2010-06-24 11:19 [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Prerna Saxena
2010-06-24 11:28 ` [Qemu-devel] [RFC v4][PATCH 1/3] Change type declarations Prerna Saxena
2010-06-24 11:31 ` [Qemu-devel] [RFC v4][PATCH 2/3] Monitor command 'info trace' Prerna Saxena
@ 2010-06-24 11:34 ` Prerna Saxena
2010-06-24 15:13 ` [Qemu-devel] Re: [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Prerna Saxena @ 2010-06-24 11:34 UTC (permalink / raw)
To: qemu-devel
Cc: Anthony Liguori, Stefan Hajnoczi, kvm, Jan Kiszka,
Luiz Capitulino, Soni, Ananth Narayan, Maneesh
This patch adds support for dynamically enabling/disabling of trace events.
This is done by internally maintaining each trace event's state, and
permitting logging of data from a trace event only if it is in an
'active' state.
Monitor commands added :
1) info trace-events : to view all available trace events and
their state.
2) trace-event NAME on|off : to enable/disable data logging from a
given trace event.
Eg, trace-event paio_submit off
disables logging of data when
paio_submit is hit.
By default, all trace-events are disabled. One can enable desired trace-events
via the monitor.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
---
monitor.c | 16 ++++++++++++++++
qemu-monitor.hx | 18 ++++++++++++++++++
simpletrace.c | 41 +++++++++++++++++++++++++++++++++++++++++
tracetool | 33 +++++++++++++++++++++++++++++----
4 files changed, 104 insertions(+), 4 deletions(-)
diff --git a/monitor.c b/monitor.c
index 8b60830..19b1ed7 100644
--- a/monitor.c
+++ b/monitor.c
@@ -548,6 +548,15 @@ static void do_commit(Monitor *mon, const QDict *qdict)
}
}
+#ifdef CONFIG_SIMPLE_TRACE
+static void do_change_trace_event_state(Monitor *mon, const QDict *qdict)
+{
+ const char *tp_name = qdict_get_str(qdict, "name");
+ bool new_state = qdict_get_bool(qdict, "option");
+ change_trace_event_state(tp_name, new_state);
+}
+#endif
+
static void user_monitor_complete(void *opaque, QObject *ret_data)
{
MonitorCompletionData *data = (MonitorCompletionData *)opaque;
@@ -2791,6 +2800,13 @@ static const mon_cmd_t info_cmds[] = {
.help = "show current contents of trace buffer",
.mhandler.info = do_info_trace,
},
+ {
+ .name = "trace-events",
+ .args_type = "",
+ .params = "",
+ .help = "show available trace-events & their state",
+ .mhandler.info = do_info_all_trace_events,
+ },
#endif
{
.name = NULL,
diff --git a/qemu-monitor.hx b/qemu-monitor.hx
index 766c30f..0fedcf9 100644
--- a/qemu-monitor.hx
+++ b/qemu-monitor.hx
@@ -117,6 +117,8 @@ show device tree
#ifdef CONFIG_SIMPLE_TRACE
@item info trace
show contents of trace buffer
+@item info trace-events
+show available trace events and their state
#endif
@end table
ETEXI
@@ -225,6 +227,22 @@ STEXI
@item logfile @var{filename}
@findex logfile
Output logs to @var{filename}.
+#ifdef CONFIG_SIMPLE_TRACE
+ETEXI
+
+ {
+ .name = "trace-event",
+ .args_type = "name:s,option:b",
+ .params = "name on|off",
+ .help = "changes status of a specific trace event",
+ .mhandler.cmd = do_change_trace_event_state,
+ },
+
+STEXI
+@item trace-event
+@findex trace-event
+changes status of a trace event
+#endif
ETEXI
{
diff --git a/simpletrace.c b/simpletrace.c
index 5734d15..57c41fc 100644
--- a/simpletrace.c
+++ b/simpletrace.c
@@ -24,6 +24,11 @@ static void trace(TraceEventID event, unsigned long x1,
unsigned long x2, unsigned long x3,
unsigned long x4, unsigned long x5) {
TraceRecord *rec = &trace_buf[trace_idx];
+
+ if (!trace_list[event].state) {
+ return;
+ }
+
rec->event = event;
rec->x1 = x1;
rec->x2 = x2;
@@ -74,3 +79,39 @@ void do_info_trace(Monitor *mon)
trace_buf[i].x3, trace_buf[i].x4, trace_buf[i].x5);
}
}
+
+void do_info_all_trace_events(Monitor *mon)
+{
+ unsigned int i;
+
+ for (i = 0; i < NR_TRACE_EVENTS; i++) {
+ monitor_printf(mon, "%s [Event ID %u] : state %u\n",
+ trace_list[i].tp_name, i, trace_list[i].state);
+ }
+}
+
+static TraceEvent* find_trace_event_by_name(const char *tname)
+{
+ unsigned int i;
+
+ if (!tname) {
+ return NULL;
+ }
+
+ for (i = 0; i < NR_TRACE_EVENTS; i++) {
+ if (!strcmp(trace_list[i].tp_name, tname)) {
+ return &trace_list[i];
+ }
+ }
+ return NULL; /* indicates end of list reached without a match */
+}
+
+void change_trace_event_state(const char *tname, bool tstate)
+{
+ TraceEvent *tp;
+
+ tp = find_trace_event_by_name(tname);
+ if (tp) {
+ tp->state = tstate;
+ }
+}
diff --git a/tracetool b/tracetool
index 6f8f8a9..9e8dbd8 100755
--- a/tracetool
+++ b/tracetool
@@ -123,14 +123,23 @@ linetoc_end_nop()
linetoh_begin_simple()
{
cat <<EOF
+#include <stdbool.h>
+
typedef unsigned int TraceEventID;
+typedef struct {
+ const char *tp_name;
+ bool state;
+} TraceEvent;
+
void trace1(TraceEventID event, unsigned long x1);
void trace2(TraceEventID event, unsigned long x1, unsigned long x2);
void trace3(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3);
void trace4(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4);
void trace5(TraceEventID event, unsigned long x1, unsigned long x2, unsigned long x3, unsigned long x4, unsigned long x5);
void do_info_trace(Monitor *mon);
+void do_info_all_trace_events(Monitor *mon);
+void change_trace_event_state(const char *tname, bool tstate);
EOF
simple_event_num=0
@@ -163,22 +172,38 @@ EOF
linetoh_end_simple()
{
- return
+ cat <<EOF
+#define NR_TRACE_EVENTS $simple_event_num
+extern TraceEvent trace_list[NR_TRACE_EVENTS];
+EOF
}
linetoc_begin_simple()
{
- return
+ cat <<EOF
+#include "trace.h"
+
+TraceEvent trace_list[] = {
+EOF
+ simple_event_num=0
+
}
linetoc_simple()
{
- return
+ local name
+ name=$(get_name "$1")
+ cat <<EOF
+{.tp_name = "$name", .state=0},
+EOF
+ simple_event_num=$((simple_event_num + 1))
}
linetoc_end_simple()
{
- return
+ cat <<EOF
+};
+EOF
}
linetoh_begin_ust()
--
1.6.2.5
--
Prerna Saxena
Linux Technology Centre,
IBM Systems and Technology Lab,
Bangalore, India
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [Qemu-devel] Re: [RFC v4][PATCH 0/3] Monitor support for Qemu tracing
2010-06-24 11:19 [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Prerna Saxena
` (2 preceding siblings ...)
2010-06-24 11:34 ` [Qemu-devel] [RFC v4][PATCH 3/3] Support for dynamically enabling/disabling trace events Prerna Saxena
@ 2010-06-24 15:13 ` Stefan Hajnoczi
3 siblings, 0 replies; 5+ messages in thread
From: Stefan Hajnoczi @ 2010-06-24 15:13 UTC (permalink / raw)
To: Prerna Saxena
Cc: Anthony Liguori, kvm, Jan Kiszka, qemu-devel, Luiz Capitulino,
Maneesh Soni, Ananth Narayan
On Thu, Jun 24, 2010 at 04:49:30PM +0530, Prerna Saxena wrote:
> This set of patches enables trace visualization & control
> via the QEMU monitor. It is based on trace infrastructure posted
> upstream :
> ( http://lists.gnu.org/archive/html/qemu-devel/2010-05/msg02407.html )
>
> This patchset adds monitor commands :
> - info trace : to view current contents of the trace buffer
> - info tracepoints : to view all available tracepoints and their state.
> - tracepoint NAME on|off : to enable/disable the logging of dataThis is v3 of a set of patches to enable trace visualization & control
> via the QEMU monitor.
>
> Changelog from v3:
> 1. As suggested, it replaces a hash-based search of tracepoints
> with a linear search.
> 2. Static initialization of trace event array.
> 3. Cleanups.
>
> Changelog from v2:
> 1. Clean-ups, particularly relating to export of tdb_hash().
>
> Changelog from v1:
> 1. Command 'info trace' is used to view current contents of buffer, in
> place of 'trace'.
> 2. Cleanups
Applied, thanks!
http://repo.or.cz/w/qemu/stefanha.git/shortlog/refs/heads/tracing
I'd like to focus on polishing the current tracing branch into a
patchset that can be merged into QEMU. Having this working prototype
enables us to try tracing out; we can commit fixes on top and then
squish the commits down for QEMU merge when the basic feature set is
solid.
> Todos :
> 1. Integration with QMP
> 2. More tracepoints need to be added for instrumenting other qemu components
> such as virtio drivers, etc.
I am copying these to another email thread so we can discuss what needs
to be done to get tracing merged.
Stefan
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-06-24 15:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-06-24 11:19 [Qemu-devel] [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Prerna Saxena
2010-06-24 11:28 ` [Qemu-devel] [RFC v4][PATCH 1/3] Change type declarations Prerna Saxena
2010-06-24 11:31 ` [Qemu-devel] [RFC v4][PATCH 2/3] Monitor command 'info trace' Prerna Saxena
2010-06-24 11:34 ` [Qemu-devel] [RFC v4][PATCH 3/3] Support for dynamically enabling/disabling trace events Prerna Saxena
2010-06-24 15:13 ` [Qemu-devel] Re: [RFC v4][PATCH 0/3] Monitor support for Qemu tracing Stefan Hajnoczi
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).