Received: from eggs.gnu.org ([140.186.70.92]:52866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R7sid-00017v-9E for qemu-devel@nongnu.org; Sun, 25 Sep 2011 13:42:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R7sic-0000ij-6q for qemu-devel@nongnu.org; Sun, 25 Sep 2011 13:42:23 -0400 Received: from gw.ac.upc.es ([147.83.30.3]:34512 helo=gw.ac.upc.edu) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R7sib-0000iJ-Q4 for qemu-devel@nongnu.org; Sun, 25 Sep 2011 13:42:22 -0400 From: =?utf-8?Q?Llu=C3=ADs_Vilanova?= References: <20110921183838.9431.70792.stgit@ginnungagap.bsc.es> Date: Sun, 25 Sep 2011 19:39:16 +0200 In-Reply-To: (Blue Swirl's message of "Sat, 24 Sep 2011 07:51:11 +0000") Message-ID: <87wrcwr06z.fsf@ginnungagap.bsc.es> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] trace: Provide a per-event status define for conditional compilation List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org, Richard Henderson Blue Swirl writes: > 2011/9/21 Llu=C3=ADs Vilanova : [...] >> +=3D=3D Trace event properties =3D=3D >> + >> +Each event in the "trace-events" file can be prefixed with a space-sepa= rated >> +list of zero or more of the following event properties. >> + >> +=3D=3D=3D "disable" =3D=3D=3D >> + >> +If a specific trace event is going to be invoked a huge number of times= , this >> +might have a noticeable performance impact even when the event is >> +programmatically disabled. >> + >> +In this case you should declare such event with the "disable" property.= This >> +will effectively disable the event at compile time (by using the "nop" = backend), >> +thus having no performance impact at all on regular builds (i.e., unles= s you >> +edit the "trace-events" file). > Nack, by default events should have no performance impact. Sure, but some events can have an impact. Then it is advisable to ship QEMU= with the "disable" property on these events, and (if necesary) use the trace_*_enabled (or TRACE_*_ENABLED) define to eliminate all possible sourc= es of performance degradation from that event. For example, the patches I sent long ago for instrumenting guest code using= TCG now use QEMU's tracing infrastructure. These events are disabled by default= , but some of them perform some computations to produce their arguments. E.g., on= e of the events has code for computing the set of used/defined registers for each instruction, which is not for free. [...] >> diff --git a/scripts/tracetool b/scripts/tracetool >> index 4c9951d..97f9f1b 100755 >> --- a/scripts/tracetool >> +++ b/scripts/tracetool >> @@ -519,7 +519,7 @@ linetostap_end_dtrace() >> =C2=A0# Process stdin by calling begin, line, and end functions for the = backend >> =C2=A0convert() >> =C2=A0{ >> - =C2=A0 =C2=A0local begin process_line end str disable >> + =C2=A0 =C2=A0local begin process_line end str name enabled >> =C2=A0 =C2=A0 begin=3D"lineto$1_begin_$backend" >> =C2=A0 =C2=A0 process_line=3D"lineto$1_$backend" >> =C2=A0 =C2=A0 end=3D"lineto$1_end_$backend" >> @@ -534,8 +534,14 @@ convert() >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 # Process the line. =C2=A0The nop backend ha= ndles disabled lines. >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 if has_property "$str" "disable"; then >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "lineto$1_nop" "$str" >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0enabled=3D0 >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 else >> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 "$process_line" "$str" >> + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0enabled=3D1 > Instead of '1', couldn't this be a function that checks if the trace > point is enabled during run time (from monitor etc.)? What you're proposing is the counterpart of 'trace_event_set_state' (in "trace/control.h"). This would miss the whole point of this patch, which is= to be able to ship QEMU with relatively costly tracing events whose performance impact can be completely eliminated at compile time. Lluis --=20 "And it's much the same thing with knowledge, for whenever you learn something new, the whole world becomes that much richer." -- The Princess of Pure Reason, as told by Norton Juster in The Phantom Tollbooth