From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
Gerd Hoffmann <kraxel@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: [PULL 2/5] docs/devel/tracing.txt: Recommend only trace_event_get_state_backends()
Date: Thu, 30 Jan 2020 21:38:11 +0000 [thread overview]
Message-ID: <20200130213814.334195-3-stefanha@redhat.com> (raw)
In-Reply-To: <20200130213814.334195-1-stefanha@redhat.com>
From: Peter Maydell <peter.maydell@linaro.org>
Instead of recommending checking the TRACE_FOO_ENABLED macro to
skip expensive computations needed only for tracing, recommend
only using trace_event_get_state_backends(). This works for both
compile-time and run-time disabling of events, and has no extra
performance impact if the event is compile-time disabled.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 20200120151142.18954-2-peter.maydell@linaro.org
Message-Id: <20200120151142.18954-2-peter.maydell@linaro.org>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
docs/devel/tracing.txt | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/docs/devel/tracing.txt b/docs/devel/tracing.txt
index 8c0376fefa..cb5f685de9 100644
--- a/docs/devel/tracing.txt
+++ b/docs/devel/tracing.txt
@@ -342,8 +342,10 @@ edit the "trace-events-all" file).
In addition, there might be cases where relatively complex computations must be
performed to generate values that are only used as arguments for a trace
-function. In these cases you can use the macro 'TRACE_${EVENT_NAME}_ENABLED' to
-guard such computations and avoid its compilation when the event is disabled:
+function. In these cases you can use 'trace_event_get_state_backends()' to
+guard such computations, so they are skipped if the event has been either
+compile-time disabled or run-time disabled. If the event is compile-time
+disabled, this check will have no performance impact.
#include "trace.h" /* needed for trace event prototype */
@@ -356,7 +358,7 @@ guard such computations and avoid its compilation when the event is disabled:
align = getpagesize();
}
ptr = qemu_memalign(align, size);
- if (TRACE_QEMU_VMALLOC_ENABLED) { /* preprocessor macro */
+ if (trace_event_get_state_backends(TRACE_QEMU_VMALLOC)) {
void *complex;
/* some complex computations to produce the 'complex' value */
trace_qemu_vmalloc(size, ptr, complex);
@@ -364,10 +366,6 @@ guard such computations and avoid its compilation when the event is disabled:
return ptr;
}
-You can check both if the event has been disabled and is dynamically enabled at
-the same time using the 'trace_event_get_state_backends' routine (see header
-"trace/control.h" for more information).
-
=== "tcg" ===
Guest code generated by TCG can be traced by defining an event with the "tcg"
--
2.24.1
next prev parent reply other threads:[~2020-01-30 21:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-30 21:38 [PULL 0/5] Tracing patches Stefan Hajnoczi
2020-01-30 21:38 ` [PULL 1/5] Makefile: Keep trace-events-subdirs ordered Stefan Hajnoczi
2020-01-30 21:38 ` Stefan Hajnoczi [this message]
2020-01-30 21:38 ` [PULL 3/5] memory.c: Use trace_event_get_state_backends() Stefan Hajnoczi
2020-01-30 21:38 ` [PULL 4/5] hw/display/qxl.c: " Stefan Hajnoczi
2020-01-30 21:38 ` [PULL 5/5] qemu_set_log_filename: filename argument may be NULL Stefan Hajnoczi
2020-02-11 22:51 ` Richard Henderson
2020-02-12 10:45 ` Alex Bennée
2020-02-12 21:41 ` Richard Henderson
2020-01-31 13:57 ` [PULL 0/5] Tracing patches Peter Maydell
2020-01-31 14:38 ` Philippe Mathieu-Daudé
2020-01-31 14:45 ` Philippe Mathieu-Daudé
2020-01-31 15:25 ` Alex Bennée
2020-01-31 19:05 ` Peter Maydell
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=20200130213814.334195-3-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=kraxel@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--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).