From: "Lluís Vilanova" <vilanova@ac.upc.edu>
To: qemu-devel@nongnu.org
Cc: Eduardo Habkost <ehabkost@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 5/6] trace: Conditionally trace events based on their per-vCPU state
Date: Thu, 25 Feb 2016 16:03:12 +0100 [thread overview]
Message-ID: <145641259192.30097.6270551195105705484.stgit@localhost> (raw)
In-Reply-To: <145641255678.30097.2919142707547689749.stgit@localhost>
Events with the 'vcpu' property are conditionally emitted according to
their per-vCPU state. Other events are emitted normally based on their
global tracing state.
Note that the per-vCPU condition check applies to all tracing backends.
Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu>
---
scripts/tracetool/backend/dtrace.py | 4 ++--
scripts/tracetool/backend/ftrace.py | 20 ++++++++++----------
scripts/tracetool/backend/log.py | 26 ++++++++++++++++----------
scripts/tracetool/backend/simple.py | 13 ++++++++++---
scripts/tracetool/backend/ust.py | 4 ++--
scripts/tracetool/format/h.py | 18 ++++++++++++++++--
6 files changed, 56 insertions(+), 29 deletions(-)
diff --git a/scripts/tracetool/backend/dtrace.py b/scripts/tracetool/backend/dtrace.py
index fabfe99..ab9ecfa 100644
--- a/scripts/tracetool/backend/dtrace.py
+++ b/scripts/tracetool/backend/dtrace.py
@@ -6,7 +6,7 @@ DTrace/SystemTAP backend.
"""
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
@@ -41,6 +41,6 @@ def generate_h_begin(events):
def generate_h(event):
- out(' QEMU_%(uppername)s(%(argnames)s);',
+ out(' QEMU_%(uppername)s(%(argnames)s);',
uppername=event.name.upper(),
argnames=", ".join(event.args.names()))
diff --git a/scripts/tracetool/backend/ftrace.py b/scripts/tracetool/backend/ftrace.py
index d798c71..80dcf30 100644
--- a/scripts/tracetool/backend/ftrace.py
+++ b/scripts/tracetool/backend/ftrace.py
@@ -30,17 +30,17 @@ def generate_h(event):
if len(event.args) > 0:
argnames = ", " + argnames
- out(' {',
- ' char ftrace_buf[MAX_TRACE_STRLEN];',
- ' int unused __attribute__ ((unused));',
- ' int trlen;',
- ' if (trace_event_get_state(%(event_id)s)) {',
- ' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
- ' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
- ' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
- ' unused = write(trace_marker_fd, ftrace_buf, trlen);',
+ out(' {',
+ ' char ftrace_buf[MAX_TRACE_STRLEN];',
+ ' int unused __attribute__ ((unused));',
+ ' int trlen;',
+ ' if (trace_event_get_state(%(event_id)s)) {',
+ ' trlen = snprintf(ftrace_buf, MAX_TRACE_STRLEN,',
+ ' "%(name)s " %(fmt)s "\\n" %(argnames)s);',
+ ' trlen = MIN(trlen, MAX_TRACE_STRLEN - 1);',
+ ' unused = write(trace_marker_fd, ftrace_buf, trlen);',
+ ' }',
' }',
- ' }',
name=event.name,
args=event.args,
event_id="TRACE_" + event.name.upper(),
diff --git a/scripts/tracetool/backend/log.py b/scripts/tracetool/backend/log.py
index a62c310..2581f6e 100644
--- a/scripts/tracetool/backend/log.py
+++ b/scripts/tracetool/backend/log.py
@@ -6,7 +6,7 @@ Stderr built-in backend.
"""
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
@@ -34,15 +34,21 @@ def generate_h(event):
if len(event.args) > 0:
argnames = ", " + argnames
- out(' if (trace_event_get_state(%(event_id)s)) {',
- ' struct timeval _now;',
- ' gettimeofday(&_now, NULL);',
- ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
- ' getpid(),',
- ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
- ' %(argnames)s);',
- ' }',
- event_id="TRACE_" + event.name.upper(),
+ if "vcpu" in event.properties:
+ # already checked on the generic format code
+ cond = "true"
+ else:
+ cond = "trace_event_get_state(%s)" % ("TRACE_" + event.name.upper())
+
+ out(' if (%(cond)s) {',
+ ' struct timeval _now;',
+ ' gettimeofday(&_now, NULL);',
+ ' qemu_log_mask(LOG_TRACE, "%%d@%%zd.%%06zd:%(name)s " %(fmt)s "\\n",',
+ ' getpid(),',
+ ' (size_t)_now.tv_sec, (size_t)_now.tv_usec',
+ ' %(argnames)s);',
+ ' }',
+ cond=cond,
name=event.name,
fmt=event.fmt.rstrip("\n"),
argnames=argnames)
diff --git a/scripts/tracetool/backend/simple.py b/scripts/tracetool/backend/simple.py
index 3246c20..1bccada 100644
--- a/scripts/tracetool/backend/simple.py
+++ b/scripts/tracetool/backend/simple.py
@@ -36,7 +36,7 @@ def generate_h_begin(events):
def generate_h(event):
- out(' _simple_%(api)s(%(args)s);',
+ out(' _simple_%(api)s(%(args)s);',
api=event.api(),
args=", ".join(event.args.names()))
@@ -68,16 +68,23 @@ def generate_c(event):
if len(event.args) == 0:
sizestr = '0'
+ event_id = 'TRACE_' + event.name.upper()
+ if "vcpu" in event.properties:
+ # already checked on the generic format code
+ cond = "true"
+ else:
+ cond = "trace_event_get_state(%s)" % event_id
out('',
- ' if (!trace_event_get_state(%(event_id)s)) {',
+ ' if (!%(cond)s) {',
' return;',
' }',
'',
' if (trace_record_start(&rec, %(event_id)s, %(size_str)s)) {',
' return; /* Trace Buffer Full, Event Dropped ! */',
' }',
- event_id='TRACE_' + event.name.upper(),
+ cond=cond,
+ event_id=event_id,
size_str=sizestr)
if len(event.args) > 0:
diff --git a/scripts/tracetool/backend/ust.py b/scripts/tracetool/backend/ust.py
index 2f8f44a..ed4c227 100644
--- a/scripts/tracetool/backend/ust.py
+++ b/scripts/tracetool/backend/ust.py
@@ -6,7 +6,7 @@ LTTng User Space Tracing backend.
"""
__author__ = "Lluís Vilanova <vilanova@ac.upc.edu>"
-__copyright__ = "Copyright 2012-2014, Lluís Vilanova <vilanova@ac.upc.edu>"
+__copyright__ = "Copyright 2012-2016, Lluís Vilanova <vilanova@ac.upc.edu>"
__license__ = "GPL version 2 or (at your option) any later version"
__maintainer__ = "Stefan Hajnoczi"
@@ -30,6 +30,6 @@ def generate_h(event):
if len(event.args) > 0:
argnames = ", " + argnames
- out(' tracepoint(qemu, %(name)s%(tp_args)s);',
+ out(' tracepoint(qemu, %(name)s%(tp_args)s);',
name=event.name,
tp_args=argnames)
diff --git a/scripts/tracetool/format/h.py b/scripts/tracetool/format/h.py
index 2bd68a2..52b24e8 100644
--- a/scripts/tracetool/format/h.py
+++ b/scripts/tracetool/format/h.py
@@ -29,16 +29,30 @@ def generate(events, backend):
backend.generate_begin(events)
for e in events:
+ if "vcpu" in e.properties:
+ trace_cpu = next(iter(e.args))[1]
+ cond = "trace_event_get_cpu_state(%(cpu)s,"\
+ " TRACE_%(id)s,"\
+ " TRACE_VCPU_%(id)s)"\
+ % dict(
+ cpu=trace_cpu,
+ id=e.name.upper())
+ else:
+ cond = "true"
+
out('',
'static inline void %(api)s(%(args)s)',
'{',
+ ' if (%(cond)s) {',
api=e.api(),
- args=e.args)
+ args=e.args,
+ cond=cond)
if "disable" not in e.properties:
backend.generate(e)
- out('}')
+ out(' }',
+ '}')
backend.generate_end(events)
next prev parent reply other threads:[~2016-02-25 15:03 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-25 15:02 [Qemu-devel] [PATCH0/6] trace: Per-vCPU tracing states Lluís Vilanova
2016-02-25 15:02 ` [Qemu-devel] [PATCH 1/6] trace: Identify events with the 'vcpu' property Lluís Vilanova
2016-06-09 12:11 ` Stefan Hajnoczi
2016-02-25 15:02 ` [Qemu-devel] [PATCH 2/6] disas: Remove unused macro '_' Lluís Vilanova
2016-06-09 8:18 ` Stefan Hajnoczi
2016-06-09 10:34 ` Lluís Vilanova
2016-02-25 15:03 ` [Qemu-devel] [PATCH 3/6] [trivial] trace: Cosmetic changes on fast-path tracing Lluís Vilanova
2016-06-09 12:11 ` Stefan Hajnoczi
2016-06-13 9:04 ` Paolo Bonzini
2016-06-13 13:39 ` Lluís Vilanova
2016-02-25 15:03 ` [Qemu-devel] [PATCH 4/6] trace: Add per-vCPU tracing states for events with the 'vcpu' property Lluís Vilanova
2016-06-09 12:07 ` Stefan Hajnoczi
2016-06-09 14:17 ` Lluís Vilanova
2016-06-10 16:25 ` Stefan Hajnoczi
2016-06-10 17:52 ` Lluís Vilanova
2016-06-13 8:38 ` Paolo Bonzini
2016-06-13 12:17 ` Lluís Vilanova
2016-06-13 9:13 ` Paolo Bonzini
2016-06-13 12:15 ` Lluís Vilanova
2016-06-13 14:08 ` Paolo Bonzini
2016-06-13 16:39 ` Lluís Vilanova
2016-06-14 8:39 ` Stefan Hajnoczi
2016-06-14 9:13 ` Paolo Bonzini
2016-06-14 12:17 ` Lluís Vilanova
2016-06-13 14:38 ` Lluís Vilanova
2016-02-25 15:03 ` Lluís Vilanova [this message]
2016-06-09 12:09 ` [Qemu-devel] [PATCH 5/6] trace: Conditionally trace events based on their per-vCPU state Stefan Hajnoczi
2016-02-25 15:03 ` [Qemu-devel] [PATCH 6/6] trace: Add QAPI/QMP interfaces to query and control per-vCPU tracing state Lluís Vilanova
2016-06-09 12:10 ` Stefan Hajnoczi
2016-03-07 19:35 ` [Qemu-devel] [PATCH0/6] trace: Per-vCPU tracing states Lluís Vilanova
2016-06-01 12:14 ` Lluís Vilanova
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=145641259192.30097.6270551195105705484.stgit@localhost \
--to=vilanova@ac.upc.edu \
--cc=ehabkost@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.com \
/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).