From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:34872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2Ic-0003Mo-Je for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qz2IV-0007gu-VF for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:58 -0400 Received: from mtagate2.uk.ibm.com ([194.196.100.162]:53918) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qz2IV-0007by-NC for qemu-devel@nongnu.org; Thu, 01 Sep 2011 04:06:51 -0400 Received: from d06nrmr1806.portsmouth.uk.ibm.com (d06nrmr1806.portsmouth.uk.ibm.com [9.149.39.193]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p8186YWG014591 for ; Thu, 1 Sep 2011 08:06:34 GMT Received: from d06av09.portsmouth.uk.ibm.com (d06av09.portsmouth.uk.ibm.com [9.149.37.250]) by d06nrmr1806.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p8186WPm2146502 for ; Thu, 1 Sep 2011 09:06:33 +0100 Received: from d06av09.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av09.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p8186Vu8020197 for ; Thu, 1 Sep 2011 02:06:31 -0600 From: Stefan Hajnoczi Date: Thu, 1 Sep 2011 09:06:22 +0100 Message-Id: <1314864386-14202-12-git-send-email-stefanha@linux.vnet.ibm.com> In-Reply-To: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> References: <1314864386-14202-1-git-send-email-stefanha@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PATCH 11/15] trace: always use the "nop" backend on events with the "disable" keyword List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , =?UTF-8?q?Llu=C3=ADs?= , =?UTF-8?q?Llu=C3=ADs=20Vilanova?= From: Llu=C3=ADs Any event with the keyword/property "disable" generates an empty trace ev= ent using the "nop" backend, regardless of the current backend. Signed-off-by: Llu=C3=ADs Vilanova --- docs/tracing.txt | 25 +++++++++++++++---------- scripts/tracetool | 15 ++------------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/docs/tracing.txt b/docs/tracing.txt index 455da37..85793cf 100644 --- a/docs/tracing.txt +++ b/docs/tracing.txt @@ -12,15 +12,11 @@ for debugging, profiling, and observing execution. ./configure --trace-backend=3Dsimple make =20 -2. Enable trace events you are interested in: - - $EDITOR trace-events # remove "disable" from events you want - -3. Run the virtual machine to produce a trace file: +2. Run the virtual machine to produce a trace file: =20 qemu ... # your normal QEMU invocation =20 -4. Pretty-print the binary trace file: +3. Pretty-print the binary trace file: =20 ./simpletrace.py trace-events trace-* =20 @@ -103,10 +99,11 @@ portability macros, ensure they are preceded and fol= lowed by double quotes: 4. Name trace events after their function. If there are multiple trace = events in one function, append a unique distinguisher at the end of the name. =20 -5. Declare trace events with the "disable" property. Some trace events = can - produce a lot of output and users are typically only interested in a = subset - of trace events. Marking trace events disabled by default saves the = user - from having to manually disable noisy trace events. +5. If specific trace events are going to be called a huge number of time= s, this + might have a noticeable performance impact even when the trace events= are + programmatically disabled. In this case you should declare the trace = event + with the "disable" property, which will effectively disable it at com= pile + time (using the "nop" backend). =20 =3D=3D Generic interface and monitor commands =3D=3D =20 @@ -165,6 +162,9 @@ The "nop" backend generates empty trace event functio= ns so that the compiler can optimize out trace events completely. This is the default and impos= es no performance penalty. =20 +Note that regardless of the selected trace backend, events with the "dis= able" +property will be generated with the "nop" backend. + =3D=3D=3D Stderr =3D=3D=3D =20 The "stderr" backend sends trace events directly to standard error. Thi= s @@ -173,6 +173,11 @@ effectively turns trace events into debug printfs. This is the simplest backend and can be used together with existing code= that uses DPRINTF(). =20 +Note that with this backend trace events cannot be programmatically +enabled/disabled. Thus, in order to trim down the amount of output and t= he +performance impact of tracing, you might want to add the "disable" prope= rty in +the "trace-events" file for those events you are not interested in. + =3D=3D=3D Simpletrace =3D=3D=3D =20 The "simple" backend supports common use cases and comes as part of the = QEMU diff --git a/scripts/tracetool b/scripts/tracetool index e649a5b..e2cf117 100755 --- a/scripts/tracetool +++ b/scripts/tracetool @@ -506,21 +506,10 @@ convert() # Skip comments and empty lines test -z "${str%%#*}" && continue =20 + echo # Process the line. The nop backend handles disabled lines. - disable=3D"0" if has_property "$str" "disable"; then - disable=3D"1" - fi - echo - if [ "$disable" =3D "1" ]; then - # Pass the disabled state as an arg for the simple - # or DTrace backends which handle it dynamically. - # For all other backends, call lineto$1_nop() - if [ $backend =3D "simple" -o "$backend" =3D "dtrace" ]; the= n - "$process_line" "$str" - else - "lineto$1_nop" "${str##disable }" - fi + "lineto$1_nop" "$str" else "$process_line" "$str" fi --=20 1.7.5.4