On Fri, Jul 21, 2017 at 08:04:17PM +0300, Lluís Vilanova wrote: > Vladimir Sementsov-Ogievskiy writes: > > > Current trace system have a drawback: parameters of trace functions > > are calculated even if corresponding tracepoint is disabled. Also, it > > looks like trace function are not actually inlined by compiler (at > > least for me). > > > Here is a fix proposal: move from function call to macros. Patch 02 > > is an example, of how to reduce extra calculations with help of > > patch 01. > > The tracing functions *were* inlined last time I checked, although things > changed quite a lot since then. Not sure that will make a lot of difference in > terms of overall performance (needs measuring). > > As for arguments, each trace event has a define TRACE_{NAME}_ENABLED that you > can use for that purpose. If this is not explained in tracing.txt, that is a > documentation bug.
It is described in docs/devel/tracing.txt: 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: #include "trace.h" /* needed for trace event prototype */ void *qemu_vmalloc(size_t size) { void *ptr; size_t align = QEMU_VMALLOC_ALIGN; if (size < align) { align = getpagesize(); } ptr = qemu_memalign(align, size); if (TRACE_QEMU_VMALLOC_ENABLED) { /* preprocessor macro */ void *complex; /* some complex computations to produce the 'complex' value */ trace_qemu_vmalloc(size, ptr, complex); } return ptr; }
signature.asc
Description: PGP signature