[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] docs/devel/tracing.txt: Recommend only trace_event_get_state_
From: |
Stefan Hajnoczi |
Subject: |
[PULL 2/5] docs/devel/tracing.txt: Recommend only trace_event_get_state_backends() |
Date: |
Thu, 30 Jan 2020 21:38:11 +0000 |
From: Peter Maydell <address@hidden>
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 <address@hidden>
Message-id: address@hidden
Message-Id: <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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
- [PULL 0/5] Tracing patches, Stefan Hajnoczi, 2020/01/30
- [PULL 1/5] Makefile: Keep trace-events-subdirs ordered, Stefan Hajnoczi, 2020/01/30
- [PULL 2/5] docs/devel/tracing.txt: Recommend only trace_event_get_state_backends(),
Stefan Hajnoczi <=
- [PULL 4/5] hw/display/qxl.c: Use trace_event_get_state_backends(), Stefan Hajnoczi, 2020/01/30
- [PULL 3/5] memory.c: Use trace_event_get_state_backends(), Stefan Hajnoczi, 2020/01/30
- [PULL 5/5] qemu_set_log_filename: filename argument may be NULL, Stefan Hajnoczi, 2020/01/30
- Re: [PULL 0/5] Tracing patches, Peter Maydell, 2020/01/31
- Re: [PULL 0/5] Tracing patches, Peter Maydell, 2020/01/31