From: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: Blue Swirl <blauwirbel@gmail.com>,
Anthony Liguori <aliguori@us.ibm.com>,
Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>,
Prerna Saxena <prerna@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH 08/14] trace: Add LTTng Userspace Tracer backend
Date: Mon, 30 Aug 2010 14:27:10 +0100 [thread overview]
Message-ID: <1283174836-6330-9-git-send-email-stefanha@linux.vnet.ibm.com> (raw)
In-Reply-To: <1283174836-6330-1-git-send-email-stefanha@linux.vnet.ibm.com>
This patch adds LTTng Userspace Tracer (UST) backend support. The UST
system requires no kernel support but libust and liburcu must be
installed.
$ ./configure --trace-backend ust
$ make
Start the UST daemon:
$ ustd &
List available tracepoints and enable some:
$ ustctl --list-markers $(pgrep qemu)
[...]
{PID: 5458, channel/marker: ust/paio_submit, state: 0, fmt: "acb %p
opaque %p sector_num %lu nb_sectors %lu type %lu" 0x4b32ba}
$ ustctl --enable-marker "ust/paio_submit" $(pgrep qemu)
Run the trace:
$ ustctl --create-trace $(pgrep qemu)
$ ustctl --start-trace $(pgrep qemu)
[...]
$ ustctl --stop-trace $(pgrep qemu)
$ ustctl --destroy-trace $(pgrep qemu)
Trace results can be viewed using lttv-gui.
More information about UST:
http://lttng.org/ust
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
trace: Check for LTTng Userspace Tracer headers
When using the 'ust' backend, check if the relevant headers are
available at host.
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
---
configure | 22 +++++++++++++++-
tracetool | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 104 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index ad21c58..d3b275d 100755
--- a/configure
+++ b/configure
@@ -904,7 +904,7 @@ echo " --enable-docs enable documentation build"
echo " --disable-docs disable documentation build"
echo " --disable-vhost-net disable vhost-net acceleration support"
echo " --enable-vhost-net enable vhost-net acceleration support"
-echo " --trace-backend=B Trace backend nop simple"
+echo " --trace-backend=B Trace backend nop simple ust"
echo " --trace-file=NAME Full PATH,NAME of file to store traces"
echo " Default:/tmp/trace-<pid>"
echo " Default:trace-<pid> on Windows"
@@ -2082,6 +2082,23 @@ if test "$?" -ne 0 ; then
exit 1
fi
+##########################################
+# For 'ust' backend, test if ust headers are present
+if test "$trace_backend" = "ust"; then
+ cat > $TMPC << EOF
+#include <ust/tracepoint.h>
+#include <ust/marker.h>
+int main(void) { return 0; }
+EOF
+ if compile_prog "" "" ; then
+ LIBS="-lust $LIBS"
+ else
+ echo "ERROR: Trace backend 'ust' does not have relevant headers available"
+ echo " on the host. Pls choose a different backend."
+ exit 1
+ fi
+fi
+##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -2484,6 +2501,9 @@ if test "$trace_backend" = "simple"; then
trace_file="\"$trace_file-%u\""
fi
echo "CONFIG_TRACE_FILE=$trace_file" >> $config_host_mak
+if test "$trace_backend" = "ust"; then
+ LIBS="-lust $LIBS"
+fi
echo "TOOLS=$tools" >> $config_host_mak
echo "ROMS=$roms" >> $config_host_mak
diff --git a/tracetool b/tracetool
index d840e6f..d10c9ee 100755
--- a/tracetool
+++ b/tracetool
@@ -13,12 +13,13 @@ set -f
usage()
{
cat >&2 <<EOF
-usage: $0 [--nop | --simple] [-h | -c]
+usage: $0 [--nop | --simple | --ust] [-h | -c]
Generate tracing code for a file on stdin.
Backends:
--nop Tracing disabled
--simple Simple built-in backend
+ --ust LTTng User Space Tracing backend
Output formats:
-h Generate .h file
@@ -225,6 +226,86 @@ linetoc_end_simple()
EOF
}
+# Clean up after UST headers which pollute the namespace
+ust_clean_namespace() {
+ cat <<EOF
+#undef mutex_lock
+#undef mutex_unlock
+#undef inline
+#undef wmb
+EOF
+}
+
+linetoh_begin_ust()
+{
+ echo "#include <ust/tracepoint.h>"
+ ust_clean_namespace
+}
+
+linetoh_ust()
+{
+ local name args argnames
+ name=$(get_name "$1")
+ args=$(get_args "$1")
+ argnames=$(get_argnames "$1")
+
+ cat <<EOF
+DECLARE_TRACE(ust_$name, TPPROTO($args), TPARGS($argnames));
+#define trace_$name trace_ust_$name
+EOF
+}
+
+linetoh_end_ust()
+{
+ return
+}
+
+linetoc_begin_ust()
+{
+ cat <<EOF
+#include <ust/marker.h>
+$(ust_clean_namespace)
+#include "trace.h"
+EOF
+}
+
+linetoc_ust()
+{
+ local name args argnames fmt
+ name=$(get_name "$1")
+ args=$(get_args "$1")
+ argnames=$(get_argnames "$1")
+ fmt=$(get_fmt "$1")
+
+ cat <<EOF
+DEFINE_TRACE(ust_$name);
+
+static void ust_${name}_probe($args)
+{
+ trace_mark(ust, $name, "$fmt", $argnames);
+}
+EOF
+
+ # Collect names for later
+ names="$names $name"
+}
+
+linetoc_end_ust()
+{
+ cat <<EOF
+static void __attribute__((constructor)) trace_init(void)
+{
+EOF
+
+ for name in $names; do
+ cat <<EOF
+ register_trace_ust_$name(ust_${name}_probe);
+EOF
+ done
+
+ echo "}"
+}
+
# Process stdin by calling begin, line, and end functions for the backend
convert()
{
@@ -282,7 +363,7 @@ tracetoc()
# Choose backend
case "$1" in
-"--nop" | "--simple") backend="${1#--}" ;;
+"--nop" | "--simple" | "--ust") backend="${1#--}" ;;
*) usage ;;
esac
shift
--
1.7.1
next prev parent reply other threads:[~2010-08-30 13:27 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-30 13:27 [Qemu-devel] [PATCH 00/14 v2] trace: Add static tracing to QEMU Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 01/14] trace: Add trace-events file for declaring trace events Stefan Hajnoczi
2010-08-30 19:50 ` [Qemu-devel] " Blue Swirl
2010-08-30 20:10 ` malc
2010-08-30 20:42 ` Blue Swirl
2010-08-30 21:01 ` Blue Swirl
2010-08-31 8:46 ` Stefan Hajnoczi
2010-08-31 18:00 ` Blue Swirl
2010-09-01 6:18 ` Stefan Hajnoczi
2010-09-01 16:03 ` [Qemu-devel] [PATCH v3] " Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 02/14] trace: Add simple built-in tracing backend Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 03/14] trace: Support for dynamically enabling/disabling trace events Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 04/14] trace: Support disabled events in trace-events Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 05/14] trace: Specify trace file name Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 06/14] trace: Add trace-file command to open/close/flush trace file Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 07/14] trace: Add trace file name command-line option Stefan Hajnoczi
2010-08-30 13:27 ` Stefan Hajnoczi [this message]
2010-08-30 13:27 ` [Qemu-devel] [PATCH 09/14] trace: Add user documentation Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 10/14] trace: Trace qemu_malloc() and qemu_vmalloc() Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 11/14] trace: Trace virtio-blk, multiwrite, and paio_submit Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 12/14] trace: Trace virtqueue operations Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 13/14] trace: Trace port IO Stefan Hajnoczi
2010-08-30 13:27 ` [Qemu-devel] [PATCH 14/14] trace: Trace entry point of balloon request handler Stefan Hajnoczi
-- strict thread matches above, loose matches on Subject: below --
2010-09-06 15:13 [Qemu-devel] [PATCH v3 00/14] trace: Add static tracing to QEMU Stefan Hajnoczi
2010-09-06 15:14 ` [Qemu-devel] [PATCH 08/14] trace: Add LTTng Userspace Tracer backend Stefan Hajnoczi
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=1283174836-6330-9-git-send-email-stefanha@linux.vnet.ibm.com \
--to=stefanha@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=prerna@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.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).